From a713ba1110de6269473ce620dd5cf352f113b47f Mon Sep 17 00:00:00 2001 From: edoardo <48774736+xdoardo@users.noreply.github.com> Date: Tue, 29 Oct 2024 03:20:05 +0100 Subject: [PATCH 001/431] fix(ios): Remove `float-abi` flag (#3889) --- product-mini/platforms/ios/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/product-mini/platforms/ios/CMakeLists.txt b/product-mini/platforms/ios/CMakeLists.txt index 4bbff4cff9..ea5a4f4b9d 100644 --- a/product-mini/platforms/ios/CMakeLists.txt +++ b/product-mini/platforms/ios/CMakeLists.txt @@ -3,8 +3,6 @@ cmake_minimum_required (VERSION 3.21) -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") - project (iwasm) set (WAMR_BUILD_PLATFORM "darwin") From 483c57de9fad9f7c2978d260bd55030e8a079a21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:20:33 +0800 Subject: [PATCH 002/431] build(deps): bump github/codeql-action from 3.26.13 to 3.27.0 (#3888) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.13 to 3.27.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.26.13...v3.27.0) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-minor ... 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 b458606c08..62bcd0c311 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.26.13 + uses: github/codeql-action/init@v3.27.0 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.26.13 + uses: github/codeql-action/analyze@v3.27.0 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.26.13 + uses: github/codeql-action/upload-sarif@v3.27.0 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 26ad7d33e7..5e331c08c6 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@af56b044b5d41c317aef5d19920b3183cb4fbbec # v2.2.4 + uses: github/codeql-action/upload-sarif@3aa71356c75a8edd8430d54dff2982203a28be45 # v2.2.4 with: sarif_file: results.sarif From a3960c834d7e95061f85a9d7a2f9e0ab716ef4c4 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 29 Oct 2024 10:58:11 +0800 Subject: [PATCH 003/431] Refine looking up aot function with index (#3882) * Refine looking up aot function with index * refine the code --- core/iwasm/aot/aot_runtime.c | 78 +++++++++++++++++++++++++++++---- core/iwasm/aot/aot_runtime.h | 25 ++++++++++- core/iwasm/common/wasm_c_api.c | 17 +------ core/iwasm/common/wasm_memory.c | 3 +- 4 files changed, 95 insertions(+), 28 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 7e6d6360c2..01e04a3ec2 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1096,11 +1096,11 @@ aot_get_default_memory(AOTModuleInstance *module_inst) } AOTMemoryInstance * -aot_get_memory_with_index(AOTModuleInstance *module_inst, uint32 index) +aot_get_memory_with_idx(AOTModuleInstance *module_inst, uint32 mem_idx) { - if ((index >= module_inst->memory_count) || !module_inst->memories) + if ((mem_idx >= module_inst->memory_count) || !module_inst->memories) return NULL; - return module_inst->memories[index]; + return module_inst->memories[mem_idx]; } static bool @@ -1282,21 +1282,78 @@ init_func_ptrs(AOTModuleInstance *module_inst, AOTModule *module, return true; } +static int +cmp_export_func_map(const void *a, const void *b) +{ + uint32 func_idx1 = ((const ExportFuncMap *)a)->func_idx; + uint32 func_idx2 = ((const ExportFuncMap *)b)->func_idx; + return func_idx1 < func_idx2 ? -1 : (func_idx1 > func_idx2 ? 1 : 0); +} + AOTFunctionInstance * -aot_get_function_instance(AOTModuleInstance *module_inst, uint32 func_idx) +aot_lookup_function_with_idx(AOTModuleInstance *module_inst, uint32 func_idx) { - AOTModule *module = (AOTModule *)module_inst->module; AOTModuleInstanceExtra *extra = (AOTModuleInstanceExtra *)module_inst->e; AOTFunctionInstance *export_funcs = (AOTFunctionInstance *)module_inst->export_functions; + AOTFunctionInstance *func_inst = NULL; + ExportFuncMap *export_func_maps, *export_func_map, key; + uint64 size; uint32 i; - /* export functions are pre-instantiated */ - for (i = 0; i < module_inst->export_func_count; i++) { - if (export_funcs[i].func_index == func_idx) - return &export_funcs[i]; + if (module_inst->export_func_count == 0) + return NULL; + + exception_lock(module_inst); + + /* create the func_idx to export_idx maps if it hasn't been created */ + if (!extra->export_func_maps) { + size = sizeof(ExportFuncMap) * (uint64)module_inst->export_func_count; + if (!(export_func_maps = extra->export_func_maps = + runtime_malloc(size, NULL, 0))) { + /* allocate memory failed, lookup the export function one by one */ + for (i = 0; i < module_inst->export_func_count; i++) { + if (export_funcs[i].func_index == func_idx) { + func_inst = &export_funcs[i]; + break; + } + } + goto unlock_and_return; + } + + for (i = 0; i < module_inst->export_func_count; i++) { + export_func_maps[i].func_idx = export_funcs[i].func_index; + export_func_maps[i].export_idx = i; + } + + qsort(export_func_maps, module_inst->export_func_count, + sizeof(ExportFuncMap), cmp_export_func_map); } + /* lookup the map to get the export_idx of the func_idx */ + key.func_idx = func_idx; + export_func_map = + bsearch(&key, extra->export_func_maps, module_inst->export_func_count, + sizeof(ExportFuncMap), cmp_export_func_map); + if (export_func_map) + func_inst = &export_funcs[export_func_map->export_idx]; + +unlock_and_return: + exception_unlock(module_inst); + return func_inst; +} + +AOTFunctionInstance * +aot_get_function_instance(AOTModuleInstance *module_inst, uint32 func_idx) +{ + AOTModule *module = (AOTModule *)module_inst->module; + AOTModuleInstanceExtra *extra = (AOTModuleInstanceExtra *)module_inst->e; + AOTFunctionInstance *func_inst; + + /* lookup from export functions first */ + if ((func_inst = aot_lookup_function_with_idx(module_inst, func_idx))) + return func_inst; + exception_lock(module_inst); /* allocate functions array if needed */ @@ -2168,6 +2225,9 @@ aot_deinstantiate(AOTModuleInstance *module_inst, bool is_sub_inst) if (module_inst->export_functions) wasm_runtime_free(module_inst->export_functions); + if (extra->export_func_maps) + wasm_runtime_free(extra->export_func_maps); + #if WASM_ENABLE_MULTI_MEMORY != 0 if (module_inst->export_memories) wasm_runtime_free(module_inst->export_memories); diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index bf5e4366c7..297b2a5b5d 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -109,6 +109,13 @@ typedef struct AOTFunctionInstance { } u; } AOTFunctionInstance; +/* Map of a function index to the element ith in + the export functions array */ +typedef struct ExportFuncMap { + uint32 func_idx; + uint32 export_idx; +} ExportFuncMap; + typedef struct AOTModuleInstanceExtra { DefPointer(const uint32 *, stack_sizes); /* @@ -120,6 +127,13 @@ typedef struct AOTModuleInstanceExtra { MemBound shared_heap_start_off; WASMModuleInstanceExtraCommon common; + + /** + * maps of func indexes to export func indexes, which + * is sorted by func index for a quick lookup and is + * created only when first time used. + */ + ExportFuncMap *export_func_maps; AOTFunctionInstance **functions; uint32 function_count; #if WASM_ENABLE_MULTI_MODULE != 0 @@ -556,6 +570,13 @@ aot_deinstantiate(AOTModuleInstance *module_inst, bool is_sub_inst); AOTFunctionInstance * aot_lookup_function(const AOTModuleInstance *module_inst, const char *name); +/** + * Lookup an exported function in the AOT module instance with + * the function index. + */ +AOTFunctionInstance * +aot_lookup_function_with_idx(AOTModuleInstance *module_inst, uint32 func_idx); + AOTMemoryInstance * aot_lookup_memory(AOTModuleInstance *module_inst, char const *name); @@ -563,7 +584,7 @@ AOTMemoryInstance * aot_get_default_memory(AOTModuleInstance *module_inst); AOTMemoryInstance * -aot_get_memory_with_index(AOTModuleInstance *module_inst, uint32 index); +aot_get_memory_with_idx(AOTModuleInstance *module_inst, uint32 mem_idx); /** * Get a function in the AOT module instance. @@ -574,7 +595,7 @@ aot_get_memory_with_index(AOTModuleInstance *module_inst, uint32 index); * @return the function instance found */ AOTFunctionInstance * -aot_get_function_instance(AOTModuleInstance *module_inst, uint32_t func_idx); +aot_get_function_instance(AOTModuleInstance *module_inst, uint32 func_idx); /** * Call the given AOT function of a AOT module instance with diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 5c1e9efd38..0c5e37eabb 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -3383,21 +3383,8 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, if (!(func_comm_rt = func->func_comm_rt)) { AOTModuleInstance *inst_aot = (AOTModuleInstance *)func->inst_comm_rt; - AOTModule *module_aot = (AOTModule *)inst_aot->module; - uint32 export_i = 0, export_func_j = 0; - - for (; export_i < module_aot->export_count; ++export_i) { - AOTExport *export = module_aot->exports + export_i; - if (export->kind == EXPORT_KIND_FUNC) { - if (export->index == func->func_idx_rt) { - func_comm_rt = - aot_lookup_function(inst_aot, export->name); - ((wasm_func_t *)func)->func_comm_rt = func_comm_rt; - break; - } - export_func_j++; - } - } + func_comm_rt = ((wasm_func_t *)func)->func_comm_rt = + aot_lookup_function_with_idx(inst_aot, func->func_idx_rt); } #endif } diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 5f5a1be90c..ff85d9f6c7 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1579,8 +1579,7 @@ wasm_runtime_get_memory(WASMModuleInstanceCommon *module_inst, uint32 index) #if WASM_ENABLE_AOT != 0 if (module_inst->module_type == Wasm_Module_AoT) - return aot_get_memory_with_index((AOTModuleInstance *)module_inst, - index); + return aot_get_memory_with_idx((AOTModuleInstance *)module_inst, index); #endif return NULL; From 95edef31857fc694bcf0d306829f53587a497b44 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 29 Oct 2024 12:26:06 +0900 Subject: [PATCH 004/431] Bump AOT_CURRENT_VERSION for WAMR 2.x (gc, memory64) (#3880) * Bump AOT_CURRENT_VERSION for WAMR 2.x (gc, memory64) Maybe it's too late because we have already made a few releases since then. But this might still help users who haven't upgraded to WAMR 2.x yet. Also, for the purpose of the versioning, it's safer to bump needlessly than missing necessary bumps. Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3837 * test-tools/aot-analyzer/include/config.h: bump AOT_CURRENT_VERSION --- core/config.h | 2 +- test-tools/aot-analyzer/include/config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/config.h b/core/config.h index 6bab4da908..f08d828d27 100644 --- a/core/config.h +++ b/core/config.h @@ -84,7 +84,7 @@ #endif #define AOT_MAGIC_NUMBER 0x746f6100 -#define AOT_CURRENT_VERSION 3 +#define AOT_CURRENT_VERSION 4 #ifndef WASM_ENABLE_JIT #define WASM_ENABLE_JIT 0 diff --git a/test-tools/aot-analyzer/include/config.h b/test-tools/aot-analyzer/include/config.h index 546b5b1673..970d7e2cc2 100644 --- a/test-tools/aot-analyzer/include/config.h +++ b/test-tools/aot-analyzer/include/config.h @@ -15,7 +15,7 @@ #define WASM_CURRENT_VERSION 1 #define AOT_MAGIC_NUMBER 0x746f6100 -#define AOT_CURRENT_VERSION 3 +#define AOT_CURRENT_VERSION 4 /* Legal values for bin_type */ #define BIN_TYPE_ELF32L 0 /* 32-bit little endian */ From 1138435455a7d149c793032b65c4a8117ce29c9f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 30 Oct 2024 13:18:54 +0800 Subject: [PATCH 005/431] Fix mmap flags for AOT loader on non-Linux SGX platforms (#3890) --- core/iwasm/aot/aot_loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 01e246aa32..c53503be20 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -304,12 +304,13 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size) #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \ || defined(BUILD_TARGET_RISCV64_LP64D) \ || defined(BUILD_TARGET_RISCV64_LP64) -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(BH_PLATFORM_LINUX_SGX) /* The mmapped AOT data and code in 64-bit targets had better be in range 0 to 2G, or aot loader may fail to apply some relocations, e.g., R_X86_64_32/R_X86_64_32S/R_X86_64_PC32/R_RISCV_32. We try to mmap with MMAP_MAP_32BIT flag first, and if fails, mmap again without the flag. */ + /* sgx_tprotect_rsrv_mem() and sgx_alloc_rsrv_mem() will ignore flags */ map_flags = MMAP_MAP_32BIT; if ((mem = os_mmap(NULL, size, map_prot, map_flags, os_get_invalid_handle()))) { From c7b2683f17b42911e5cbd2b22502f483d882047d Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 31 Oct 2024 12:44:55 +0800 Subject: [PATCH 006/431] Fix out of bounds issue in is_native_addr_in_shared_heap function (#3886) When checking for integer overflow, you may often write tests like p + i < p. This works fine if p and i are unsigned integers, since any overflow in the addition will cause the value to simply "wrap around." However, using this pattern when p is a pointer is problematic because pointer overflow has undefined behavior according to the C and C++ standards. If the addition overflows and has an undefined result, the comparison will likewise be undefined; it may produce an unintended result, or may be deleted entirely by an optimizing compiler. --- core/iwasm/common/wasm_memory.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index ff85d9f6c7..74df84e56c 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -420,13 +420,31 @@ is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, uint8 *addr, uint32 bytes) { WASMSharedHeap *heap = get_shared_heap(module_inst); + uintptr_t base_addr; + uintptr_t addr_int; + uintptr_t end_addr; - if (heap && addr >= heap->base_addr - && addr + bytes <= heap->base_addr + heap->size - && addr + bytes > addr) { - return true; + if (!heap) { + return false; } - return false; + + base_addr = (uintptr_t)heap->base_addr; + addr_int = (uintptr_t)addr; + if (addr_int < base_addr) { + return false; + } + + end_addr = addr_int + bytes; + /* Check for overflow */ + if (end_addr <= addr_int) { + return false; + } + + if (end_addr > base_addr + heap->size) { + return false; + } + + return true; } uint64 From e352f0ab101116c46a5a615d5139b70e8e9a3d47 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 1 Nov 2024 10:16:24 +0800 Subject: [PATCH 007/431] Refactor AOT loader to support compatible versions (#3891) This commit refactors the AOT loader in `aot_loader.c` to support compatible versions of the AOT_CURRENT_VERSION constant. Previously, the loader only accepted the exact AOT_CURRENT_VERSION value, but now it also accepts version 3. This change ensures that the runtime can load modules AoT-compiled with different versions of wamrc as long as they have compatible AOT_CURRENT_VERSION values. Related to #3880. --- core/iwasm/aot/aot_loader.c | 12 +++++++++++- doc/build_wasm_app.md | 14 +++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index c53503be20..dd26bbee5c 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -4236,6 +4236,16 @@ create_sections(AOTModule *module, const uint8 *buf, uint32 size, return false; } +static bool +aot_compatible_version(uint32 version) +{ + /* + * refer to "AoT-compiled module compatibility among WAMR versions" in + * ./doc/biuld_wasm_app.md + */ + return version == 4 || version == 3; +} + static bool load(const uint8 *buf, uint32 size, AOTModule *module, bool wasm_binary_freeable, bool no_resolve, char *error_buf, @@ -4254,7 +4264,7 @@ load(const uint8 *buf, uint32 size, AOTModule *module, } read_uint32(p, p_end, version); - if (version != AOT_CURRENT_VERSION) { + if (!aot_compatible_version(version)) { set_error_buf(error_buf, error_buf_size, "unknown binary version"); return false; } diff --git a/doc/build_wasm_app.md b/doc/build_wasm_app.md index 7747d9ac39..9536d1a8d1 100644 --- a/doc/build_wasm_app.md +++ b/doc/build_wasm_app.md @@ -377,15 +377,23 @@ Examples: wamrc -o test.aot test.wasm When making major ABI changes for AoT-compiled modules, we bump `AOT_CURRENT_VERSION` constant in `core/config.h` header. The runtime rejects to load a module AoT-compiled with wamrc with -a different `AOT_CURRENT_VERSION`. +a non-compatible`AOT_CURRENT_VERSION`. We try our best to maintain our runtime ABI for AoT-compiled modules -compatible among WAMR versions with the same `AOT_CURRENT_VERSION` +compatible among WAMR versions with compatible `AOT_CURRENT_VERSION` so that combinations of older wamrc and newer runtime usually work. However, there might be minor incompatibilities time to time. -For productions, we recommend to use the exactly same version of +For productions, we recommend to use compatible versions of wamrc and the runtime. +| WAMR version | AOT_CURRENT_VERSION | Compatible AOT version | +| ------------ | ------------------- | ---------------------- | +| 1.x | 3 | 3 | +| 2.0.0 | 3 | 3 | +| 2.1.x | 3 | 3 | +| 2.2.0 | 3 | 3 | +| next | 4 | 3,4 | + ## AoT compilation with 3rd-party toolchains `wamrc` uses LLVM to compile wasm bytecode to AoT file, this works for most of the architectures, but there may be circumstances where you want to use 3rd-party toolchains to take over some steps of the compilation pipeline, e.g. From bf78863c5611de857caae3a998cbbf441dbd90cd Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:38:42 +0800 Subject: [PATCH 008/431] Wasm loader enhancement: check code size in code entry (#3892) add wasm loader check: in code entry, the code size should match the size of vec(locals) + expr, and expr should end with opcode end --- core/iwasm/interpreter/wasm_loader.c | 26 +++++++++++++++-------- core/iwasm/interpreter/wasm_mini_loader.c | 2 ++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index ae823d7be0..04fa2473ec 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3610,6 +3610,17 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, #endif } + /* Code size in code entry can't be smaller than size of vec(locals) + * + expr(at least 1 for opcode end). And expressions are encoded by + * their instruction sequence terminated with an explicit 0x0B + * opcode for end. */ + if (p_code_end <= p_code || *(p_code_end - 1) != WASM_OP_END) { + set_error_buf( + error_buf, error_buf_size, + "section size mismatch: function body END opcode expected"); + return false; + } + /* Alloc memory, layout: function structure + local types */ code_size = (uint32)(p_code_end - p_code); @@ -15837,15 +15848,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } if (loader_ctx->csp_num > 0) { - if (cur_func_idx < module->function_count - 1) - /* Function with missing end marker (between two functions) */ - set_error_buf(error_buf, error_buf_size, "END opcode expected"); - else - /* Function with missing end marker - (at EOF or end of code sections) */ - set_error_buf(error_buf, error_buf_size, - "unexpected end of section or function, " - "or section size mismatch"); + /* unmatched end opcodes result from unbalanced control flow structures, + * for example, br_table with inconsistent target count (1 declared, 2 + * given), or simply superfluous end opcodes */ + set_error_buf( + error_buf, error_buf_size, + "unexpected end opcodes from unbalanced control flow structures"); goto fail; } diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 0d1f837049..006a38c1ce 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -1183,6 +1183,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, local_count += sub_local_count; } + bh_assert(p_code_end > p_code && *(p_code_end - 1) == WASM_OP_END); + /* Alloc memory, layout: function structure + local types */ code_size = (uint32)(p_code_end - p_code); From 397f6633491052a3d4607039f6a87834b9a8524e Mon Sep 17 00:00:00 2001 From: Fadumina Barre Date: Fri, 8 Nov 2024 08:26:37 +0000 Subject: [PATCH 009/431] fix(uwp): Gate NTSTATUS definition behind WINAPI_PARTITION_DESKTOP for UWP builds --- core/shared/platform/windows/win_clock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/shared/platform/windows/win_clock.c b/core/shared/platform/windows/win_clock.c index ec0bc85664..c402330aad 100644 --- a/core/shared/platform/windows/win_clock.c +++ b/core/shared/platform/windows/win_clock.c @@ -10,9 +10,11 @@ #define NANOSECONDS_PER_SECOND 1000000000ULL #define NANOSECONDS_PER_TICK 100 +#if WINAPI_PARTITION_DESKTOP extern NTSTATUS NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution, PULONG CurrentResolution); +#endif static __wasi_errno_t calculate_monotonic_clock_frequency(uint64 *out_frequency) From fdda259d362b418f1f2a624c10d5a44bcdf81d51 Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 12 Nov 2024 22:52:27 -0800 Subject: [PATCH 010/431] Fix linked global initialization in multimodule (#3905) While resolving linked globals in multi-module mode, WAMR tries to copy the linked global's initial value into the destination global in the current module. However, a bug in the implementation causes the copy to be done from the InitializerExpression struct, not from its WASMValue field. This did not come up in WAMR's spec test runner because those are built with WASM_ENABLE_SPEC_TEST, which means these globals are resolved as builtins, not linked globals, which goes through a different (presumably not faulty) path. --- core/iwasm/interpreter/wasm_runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index accb403196..0f1ccd9371 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -1209,7 +1209,7 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst, /* The linked global instance has been initialized, we just need to copy the value. */ bh_memcpy_s(&(global->initial_value), sizeof(WASMValue), - &(global_import->import_global_linked->init_expr), + &(global_import->import_global_linked->init_expr.u), sizeof(WASMValue)); } else From 75f5fa46ab7064951b7f1fa4487c67f01a9762b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:11:11 +0800 Subject: [PATCH 011/431] build(deps): bump github/codeql-action from 3.27.0 to 3.27.1 (#3902) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.1. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.0...v3.27.1) --- 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 62bcd0c311..a3228e20d3 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.27.0 + uses: github/codeql-action/init@v3.27.1 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.27.0 + uses: github/codeql-action/analyze@v3.27.1 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.27.0 + uses: github/codeql-action/upload-sarif@v3.27.1 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 5e331c08c6..28efecc477 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@3aa71356c75a8edd8430d54dff2982203a28be45 # v2.2.4 + uses: github/codeql-action/upload-sarif@acb9cb18eec7e3a113ef83cff0be91e75cfd9526 # v2.2.4 with: sarif_file: results.sarif From 226bf22f9e61c33345d831c16e756ec40a90b689 Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 12 Nov 2024 23:11:33 -0800 Subject: [PATCH 012/431] GlobalValueSet was moved to IRPartitionLayer recently, but we have a local definition anyway (#3899) --- core/iwasm/compilation/aot_orc_extra.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/iwasm/compilation/aot_orc_extra.cpp b/core/iwasm/compilation/aot_orc_extra.cpp index dad9e04c02..d9cf3e711f 100644 --- a/core/iwasm/compilation/aot_orc_extra.cpp +++ b/core/iwasm/compilation/aot_orc_extra.cpp @@ -177,7 +177,7 @@ LLVMOrcLLLazyJITBuilderSetJITTargetMachineBuilder( LLVMOrcDisposeJITTargetMachineBuilder(JTMP); } -static Optional +static Optional PartitionFunction(GlobalValueSet Requested) { std::vector GVsToAdd; From 0e4dffc47922bb6fcdcaed7de2a6edfe8c48a7cd Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:16:13 +0800 Subject: [PATCH 013/431] Fix a leak in wasm_loader_emit_br_info (#3900) Reference Info: 377955855 wamr:wasm_mutator_fuzz_loader: Direct-leak in wasm_loader_emit_br_info https://issues.oss-fuzz.com/issues/377955855 --- core/iwasm/common/wasm_application.c | 3 ++- core/iwasm/interpreter/wasm_loader.c | 22 +++++++++++++--------- core/iwasm/interpreter/wasm_mini_loader.c | 18 +++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index 3b3be16c05..b5928d95c1 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -105,7 +105,8 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[]) bool ret, is_import_func = true, is_memory64 = false; #if WASM_ENABLE_MEMORY64 != 0 WASMModuleInstance *wasm_module_inst = (WASMModuleInstance *)module_inst; - is_memory64 = wasm_module_inst->memories[0]->is_memory64; + if (wasm_module_inst->memory_count > 0) + is_memory64 = wasm_module_inst->memories[0]->is_memory64; #endif exec_env = wasm_runtime_get_exec_env_singleton(module_inst); diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 04fa2473ec..4184562108 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -9885,13 +9885,6 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, } #endif /* WASM_ENABLE_FAST_INTERP */ -#define RESERVE_BLOCK_RET() \ - do { \ - if (!reserve_block_ret(loader_ctx, opcode, disable_emit, error_buf, \ - error_buf_size)) \ - goto fail; \ - } while (0) - #define PUSH_TYPE(type) \ do { \ if (!(wasm_loader_push_frame_ref(loader_ctx, type, error_buf, \ @@ -11612,7 +11605,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_FAST_INTERP != 0 /* if the result of if branch is in local or const area, add a * copy op */ - RESERVE_BLOCK_RET(); + if (!reserve_block_ret(loader_ctx, opcode, disable_emit, + error_buf, error_buf_size)) { + goto fail; + } emit_empty_label_addr_and_frame_ip(PATCH_END); apply_label_patch(loader_ctx, 1, PATCH_ELSE); @@ -11672,7 +11668,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); /* copy the result to the block return address */ - RESERVE_BLOCK_RET(); + if (!reserve_block_ret(loader_ctx, opcode, disable_emit, + error_buf, error_buf_size)) { + /* it could be tmp frame_csp allocated from opcode like + * OP_BR and not counted in loader_ctx->csp_num, it won't + * be freed in wasm_loader_ctx_destroy(loader_ctx) so need + * to free the loader_ctx->frame_csp if fails */ + free_label_patch_list(loader_ctx->frame_csp); + goto fail; + } apply_label_patch(loader_ctx, 0, PATCH_END); free_label_patch_list(loader_ctx->frame_csp); diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 006a38c1ce..a1fb3102fa 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -5592,13 +5592,6 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, #endif /* WASM_ENABLE_FAST_INTERP */ -#define RESERVE_BLOCK_RET() \ - do { \ - if (!reserve_block_ret(loader_ctx, opcode, disable_emit, error_buf, \ - error_buf_size)) \ - goto fail; \ - } while (0) - #define PUSH_TYPE(type) \ do { \ if (!(wasm_loader_push_frame_ref(loader_ctx, type, error_buf, \ @@ -6366,7 +6359,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_FAST_INTERP != 0 /* if the result of if branch is in local or const area, add a * copy op */ - RESERVE_BLOCK_RET(); + if (!reserve_block_ret(loader_ctx, opcode, disable_emit, + error_buf, error_buf_size)) { + goto fail; + } emit_empty_label_addr_and_frame_ip(PATCH_END); apply_label_patch(loader_ctx, 1, PATCH_ELSE); @@ -6426,7 +6422,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); /* copy the result to the block return address */ - RESERVE_BLOCK_RET(); + if (!reserve_block_ret(loader_ctx, opcode, disable_emit, + error_buf, error_buf_size)) { + free_label_patch_list(loader_ctx->frame_csp); + goto fail; + } apply_label_patch(loader_ctx, 0, PATCH_END); free_label_patch_list(loader_ctx->frame_csp); From 0119b17526ae447c5c57784d9deb90c04af51fe5 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 18 Nov 2024 20:01:00 +0800 Subject: [PATCH 014/431] Correct the table index calculation in aot_instantiation (#3903) `module_inst->table_count = module->import_table_count + module->table_count`, using it as an index will go through `module->import_tables` and `module->tables`, but aot init data is only available for non-import tables. --- core/iwasm/aot/aot_runtime.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 01e04a3ec2..5d50f255ca 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1785,7 +1785,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, bool ret = false; #endif - /* Check heap size */ + /* Align and validate heap size */ heap_size = align_uint(heap_size, 8); if (heap_size > APP_HEAP_SIZE_MAX) heap_size = APP_HEAP_SIZE_MAX; @@ -2001,7 +2001,11 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, AOTTableInstance *table_inst; table_elem_type_t *table_data; - table = &module->tables[i]; + /* bypass imported table since AOTImportTable doesn't have init_expr */ + if (i < module->import_table_count) + continue; + + table = &module->tables[i - module->import_table_count]; bh_assert(table); if (table->init_expr.init_expr_type == INIT_EXPR_NONE) { From 2975e2ffb8e83691c1dbaa685253c2d4bf63b03b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:45:50 +0800 Subject: [PATCH 015/431] build(deps): bump github/codeql-action from 3.27.1 to 3.27.4 (#3912) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.1 to 3.27.4. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.1...v3.27.4) --- 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 a3228e20d3..c71f305aae 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.27.1 + uses: github/codeql-action/init@v3.27.4 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.27.1 + uses: github/codeql-action/analyze@v3.27.4 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.27.1 + uses: github/codeql-action/upload-sarif@v3.27.4 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 28efecc477..1d5baa6b14 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@acb9cb18eec7e3a113ef83cff0be91e75cfd9526 # v2.2.4 + uses: github/codeql-action/upload-sarif@a1695c562bbfa68dc5ab58c9b5e9f616b52bf5be # v2.2.4 with: sarif_file: results.sarif From f2b87d773e88790fd2eac89d828f78836c219900 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:47:05 +0800 Subject: [PATCH 016/431] Support external toolchain on Windows for aot compiler (#3911) allowing custom ARC toolchain on Windows --- build-scripts/build_llvm.py | 20 ++++++++- core/iwasm/compilation/aot_compiler.c | 43 ++----------------- core/iwasm/compilation/aot_emit_aot_file.c | 20 ++------- core/iwasm/compilation/aot_llvm.c | 10 ----- core/iwasm/compilation/aot_llvm.h | 12 ++++++ core/shared/utils/bh_common.c | 50 ++++++++++++++++++++++ core/shared/utils/bh_common.h | 10 +++++ 7 files changed, 97 insertions(+), 68 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index 7de55b6a0c..ec6bb39548 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -102,12 +102,27 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl "default": [], } + experimental_backends = ["ARC", "Xtensa"] + normal_backends = [s for s in backends if s not in experimental_backends] + LLVM_TARGETS_TO_BUILD = [ - '-DLLVM_TARGETS_TO_BUILD:STRING="' + ";".join(backends) + '"' - if backends + '-DLLVM_TARGETS_TO_BUILD:STRING="' + ";".join(normal_backends) + '"' + if normal_backends else '-DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;Mips;RISCV;X86"' ] + # if not on ARC platform, but want to add expeirmental backend ARC as target + if platform != "ARC" and "ARC" in backends: + LLVM_TARGETS_TO_BUILD.extend( + 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 "" ] @@ -240,6 +255,7 @@ def main(): "X86", "Xtensa", ], + default=[], help="identify LLVM supported backends, separate by space, like '--arch ARM Mips X86'", ) parser.add_argument( diff --git a/core/iwasm/compilation/aot_compiler.c b/core/iwasm/compilation/aot_compiler.c index 07734b3b41..82f70ca3dc 100644 --- a/core/iwasm/compilation/aot_compiler.c +++ b/core/iwasm/compilation/aot_compiler.c @@ -4093,39 +4093,6 @@ aot_compile_wasm(AOTCompContext *comp_ctx) return true; } -#if !(defined(_WIN32) || defined(_WIN32_)) -char * -aot_generate_tempfile_name(const char *prefix, const char *extension, - char *buffer, uint32 len) -{ - int fd, name_len; - - name_len = snprintf(buffer, len, "%s-XXXXXX", prefix); - - if ((fd = mkstemp(buffer)) <= 0) { - aot_set_last_error("make temp file failed."); - return NULL; - } - - /* close and remove temp file */ - close(fd); - unlink(buffer); - - /* Check if buffer length is enough */ - /* name_len + '.' + extension + '\0' */ - if (name_len + 1 + strlen(extension) + 1 > len) { - aot_set_last_error("temp file name too long."); - return NULL; - } - - snprintf(buffer + name_len, len - name_len, ".%s", extension); - return buffer; -} -#else - -errno_t -_mktemp_s(char *nameTemplate, size_t sizeInChars); - char * aot_generate_tempfile_name(const char *prefix, const char *extension, char *buffer, uint32 len) @@ -4134,7 +4101,8 @@ aot_generate_tempfile_name(const char *prefix, const char *extension, name_len = snprintf(buffer, len, "%s-XXXXXX", prefix); - if (_mktemp_s(buffer, name_len + 1) != 0) { + if (!bh_mkstemp(buffer, name_len + 1)) { + aot_set_last_error("make temp file failed."); return NULL; } @@ -4148,7 +4116,6 @@ aot_generate_tempfile_name(const char *prefix, const char *extension, snprintf(buffer + name_len, len - name_len, ".%s", extension); return buffer; } -#endif /* end of !(defined(_WIN32) || defined(_WIN32_)) */ bool aot_emit_llvm_file(AOTCompContext *comp_ctx, const char *file_name) @@ -4227,7 +4194,6 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name) bh_print_time("Begin to emit object file"); -#if !(defined(_WIN32) || defined(_WIN32_)) if (comp_ctx->external_llc_compiler || comp_ctx->external_asm_compiler) { char cmd[1024]; int ret; @@ -4270,7 +4236,7 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name) file_name, bc_file_name); LOG_VERBOSE("invoking external LLC compiler:\n\t%s", cmd); - ret = system(cmd); + ret = bh_system(cmd); /* remove temp bitcode file */ unlink(bc_file_name); @@ -4323,7 +4289,7 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name) file_name, asm_file_name); LOG_VERBOSE("invoking external ASM compiler:\n\t%s", cmd); - ret = system(cmd); + ret = bh_system(cmd); /* remove temp assembly file */ unlink(asm_file_name); @@ -4336,7 +4302,6 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name) return true; } -#endif /* end of !(defined(_WIN32) || defined(_WIN32_)) */ if (!strncmp(LLVMGetTargetName(target), "arc", 3)) /* Emit to assembly file instead for arc target diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 8fa2053083..9b2436a2bd 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -4292,10 +4292,6 @@ aot_obj_data_create(AOTCompContext *comp_ctx) bh_print_time("Begin to emit object file"); if (comp_ctx->external_llc_compiler || comp_ctx->external_asm_compiler) { -#if defined(_WIN32) || defined(_WIN32_) - aot_set_last_error("external toolchain not supported on Windows"); - goto fail; -#else /* Generate a temp file name */ int ret; char obj_file_name[64]; @@ -4323,27 +4319,18 @@ aot_obj_data_create(AOTCompContext *comp_ctx) aot_set_last_error("create mem buffer with file failed."); goto fail; } -#endif /* end of defined(_WIN32) || defined(_WIN32_) */ } else if (!strncmp(LLVMGetTargetName(target), "arc", 3)) { -#if defined(_WIN32) || defined(_WIN32_) - aot_set_last_error("emit object file on Windows is unsupported."); - goto fail; -#else /* Emit to assembly file instead for arc target as it cannot emit to object file */ char file_name[] = "wasm-XXXXXX", buf[128]; - int fd, ret; + int ret; - if ((fd = mkstemp(file_name)) <= 0) { + if (!bh_mkstemp(file_name, sizeof(file_name))) { aot_set_last_error("make temp file failed."); goto fail; } - /* close and remove temp file */ - close(fd); - unlink(file_name); - snprintf(buf, sizeof(buf), "%s%s", file_name, ".s"); if (LLVMTargetMachineEmitToFile(comp_ctx->target_machine, comp_ctx->module, buf, LLVMAssemblyFile, @@ -4364,7 +4351,7 @@ aot_obj_data_create(AOTCompContext *comp_ctx) "/opt/zephyr-sdk/arc-zephyr-elf/bin/arc-zephyr-elf-gcc ", "-mcpu=arcem -o ", file_name, ".o -c ", file_name, ".s"); /* TODO: use try..catch to handle possible exceptions */ - ret = system(buf); + ret = bh_system(buf); /* remove temp assembly file */ snprintf(buf, sizeof(buf), "%s%s", file_name, ".s"); unlink(buf); @@ -4391,7 +4378,6 @@ aot_obj_data_create(AOTCompContext *comp_ctx) aot_set_last_error("create mem buffer with file failed."); goto fail; } -#endif /* end of defined(_WIN32) || defined(_WIN32_) */ } else { if (LLVMTargetMachineEmitToMemoryBuffer( diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index fb1c4308b2..14ee4dd2b7 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2746,10 +2746,6 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) /* verify external llc compiler */ comp_ctx->external_llc_compiler = getenv("WAMRC_LLC_COMPILER"); if (comp_ctx->external_llc_compiler) { -#if defined(_WIN32) || defined(_WIN32_) - comp_ctx->external_llc_compiler = NULL; - LOG_WARNING("External LLC compiler not supported on Windows."); -#else if (access(comp_ctx->external_llc_compiler, X_OK) != 0) { LOG_WARNING("WAMRC_LLC_COMPILER [%s] not found, fallback to " "default pipeline", @@ -2761,17 +2757,12 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) LOG_VERBOSE("Using external LLC compiler [%s]", comp_ctx->external_llc_compiler); } -#endif } /* verify external asm compiler */ if (!comp_ctx->external_llc_compiler) { comp_ctx->external_asm_compiler = getenv("WAMRC_ASM_COMPILER"); if (comp_ctx->external_asm_compiler) { -#if defined(_WIN32) || defined(_WIN32_) - comp_ctx->external_asm_compiler = NULL; - LOG_WARNING("External ASM compiler not supported on Windows."); -#else if (access(comp_ctx->external_asm_compiler, X_OK) != 0) { LOG_WARNING( "WAMRC_ASM_COMPILER [%s] not found, fallback to " @@ -2784,7 +2775,6 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) LOG_VERBOSE("Using external ASM compiler [%s]", comp_ctx->external_asm_compiler); } -#endif } } diff --git a/core/iwasm/compilation/aot_llvm.h b/core/iwasm/compilation/aot_llvm.h index 0dce988bc9..9c608d301e 100644 --- a/core/iwasm/compilation/aot_llvm.h +++ b/core/iwasm/compilation/aot_llvm.h @@ -37,6 +37,18 @@ #include "aot_orc_extra.h" #include "aot_comp_option.h" +#if defined(_WIN32) || defined(_WIN32_) +#include +#define access _access +/* On windows there is no X_OK flag to check for executablity, only check for + * existence */ +#ifdef X_OK +#undef X_OK +#endif +#define X_OK 00 +#define unlink _unlink +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/core/shared/utils/bh_common.c b/core/shared/utils/bh_common.c index 7fe123c912..62f36caf1a 100644 --- a/core/shared/utils/bh_common.c +++ b/core/shared/utils/bh_common.c @@ -165,3 +165,53 @@ wa_strdup(const char *s) } return s1; } + +#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 +int +bh_system(const char *cmd) +{ + int ret; + +#if !(defined(_WIN32) || defined(_WIN32_)) + ret = system(cmd); +#else + ret = _spawnlp(_P_WAIT, "cmd.exe", "/c", cmd, NULL); +#endif + + return ret; +} + +#if defined(_WIN32) || defined(_WIN32_) +errno_t +_mktemp_s(char *nameTemplate, size_t sizeInChars); +#endif + +bool +bh_mkstemp(char *file_name, size_t name_len) +{ + int fd; + +#if !(defined(_WIN32) || defined(_WIN32_)) + (void)name_len; + /* On Linux, it generates a unique temporary filename from template, creates + * and opens the file, and returns an open file descriptor for the file. */ + if ((fd = mkstemp(file_name)) <= 0) { + goto fail; + } + + /* close and remove temp file */ + close(fd); + unlink(file_name); +#else + /* On Windows, it generates a unique temporary file name but does not create + * or open the file */ + if (_mktemp_s(file_name, name_len) != 0) { + goto fail; + } +#endif + + return true; +fail: + return false; +} +#endif /* End of WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 */ diff --git a/core/shared/utils/bh_common.h b/core/shared/utils/bh_common.h index adae722bbc..093e622081 100644 --- a/core/shared/utils/bh_common.h +++ b/core/shared/utils/bh_common.h @@ -66,6 +66,16 @@ bh_strdup(const char *s); char * wa_strdup(const char *s); +#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 +/* Executes a system command in bash/cmd.exe */ +int +bh_system(const char *cmd); + +/* Tests whether can create a temporary file with the given name */ +bool +bh_mkstemp(char *filename, size_t name_len); +#endif + #ifdef __cplusplus } #endif From f1d03db8e58a268e1745ece954b44772c9522349 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:22:36 +0800 Subject: [PATCH 017/431] Fix CI wamr-ide error (#3913) The recent version of the rust toolchain will emit ref types opcodes, which needs to enable this feature in the `iwasm` build. The vector format parsing logic has some errors in the current version. I disabled the check for now and am waiting for further investigation. --- .github/workflows/compilation_on_android_ubuntu.yml | 2 +- .../src/test/suite/extension.test.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 8ba6e0e809..1ea36418e5 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -828,7 +828,7 @@ jobs: run: | mkdir build cd build - cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 + cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1 make working-directory: product-mini/platforms/linux diff --git a/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts b/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts index d1420dfa5e..91d54853ea 100644 --- a/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts +++ b/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts @@ -196,11 +196,14 @@ suite('Inegration Tests', function () { ); // Vector - assert.equal( - namesToVariables['vector'].value, - ' (5) vec![1, 2, 3, 4, 12]', - 'The Vector summary string looks different than expected' - ); + // TODO: The vector format conversion have some problem now, can't see the actual value + // - (5) vec![{...}, {...}, {...}, {...}, {...}, ...] + // + (5) vec![1, 2, 3, 4, 12] + // assert.equal( + // namesToVariables['vector'].value, + // ' (5) vec![1, 2, 3, 4, 12]', + // 'The Vector summary string looks different than expected' + // ); // Map assert.equal( From 62aca1727908848c194dfe52c7d62397f5df8441 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:01:24 +0800 Subject: [PATCH 018/431] Check possible integer overflow in aot memory boundary check (#3920) Check possible integer overflow in aot memory boundary check when the wasm memory is 64-bit. --- core/iwasm/compilation/aot_emit_memory.c | 38 ++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/core/iwasm/compilation/aot_emit_memory.c b/core/iwasm/compilation/aot_emit_memory.c index 869a1dbb27..9adf96ac52 100644 --- a/core/iwasm/compilation/aot_emit_memory.c +++ b/core/iwasm/compilation/aot_emit_memory.c @@ -273,10 +273,24 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, } /* offset1 = offset + addr; */ - /* TODO: check whether integer overflow occurs when memory is 64-bit - and boundary check is enabled */ BUILD_OP(Add, offset_const, addr, offset1, "offset1"); + if (is_memory64 && comp_ctx->enable_bound_check) { + /* Check whether integer overflow occurs in offset + addr */ + LLVMBasicBlockRef check_integer_overflow_end; + ADD_BASIC_BLOCK(check_integer_overflow_end, + "check_integer_overflow_end"); + LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr); + + BUILD_ICMP(LLVMIntULT, offset1, offset_const, cmp1, "cmp1"); + if (!aot_emit_exception(comp_ctx, func_ctx, + EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp1, + check_integer_overflow_end)) { + goto fail; + } + SET_BUILD_POS(check_integer_overflow_end); + } + if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; LLVMValueRef is_in_shared_heap, shared_heap_check_bound = NULL; @@ -303,7 +317,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMPositionBuilderAtEnd(comp_ctx->builder, block_curr); if (!is_target_64bit) { - /* Check whether interger overflow occurs in addr + offset */ + /* Check whether integer overflow occurs in addr + offset */ LLVMBasicBlockRef check_integer_overflow_end; ADD_BASIC_BLOCK(check_integer_overflow_end, "check_integer_overflow_end"); @@ -1215,10 +1229,24 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } - /* TODO: check whether integer overflow occurs when memory is 64-bit - and boundary check is enabled */ BUILD_OP(Add, offset, bytes, max_addr, "max_addr"); + if (is_memory64 && comp_ctx->enable_bound_check) { + /* Check whether integer overflow occurs in offset + addr */ + LLVMBasicBlockRef check_integer_overflow_end; + ADD_BASIC_BLOCK(check_integer_overflow_end, + "check_integer_overflow_end"); + LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr); + + BUILD_ICMP(LLVMIntULT, max_addr, offset, cmp, "cmp"); + if (!aot_emit_exception(comp_ctx, func_ctx, + EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp, + check_integer_overflow_end)) { + goto fail; + } + SET_BUILD_POS(check_integer_overflow_end); + } + if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; LLVMValueRef shared_heap_start_off, shared_heap_check_bound; From 00c2aa10a8428aa38a0197c97455a8bc3a24937d Mon Sep 17 00:00:00 2001 From: James Ring Date: Sat, 23 Nov 2024 19:30:00 -0800 Subject: [PATCH 019/431] Drop declarative elements on module instantiation (#3922) --- core/iwasm/aot/aot_runtime.c | 4 +++- core/iwasm/interpreter/wasm_runtime.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 5d50f255ca..8a33a72716 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1905,7 +1905,9 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, goto fail; } for (i = 0; i < module->table_init_data_count; i++) { - if (wasm_elem_is_active(module->table_init_data_list[i]->mode)) + if (wasm_elem_is_active(module->table_init_data_list[i]->mode) + || wasm_elem_is_declarative( + module->table_init_data_list[i]->mode)) bh_bitmap_set_bit(common->elem_dropped, i); } } diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 0f1ccd9371..f9378aac98 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -2467,7 +2467,8 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, goto fail; } for (i = 0; i < module->table_seg_count; i++) { - if (wasm_elem_is_active(module->table_segments[i].mode)) + if (wasm_elem_is_active(module->table_segments[i].mode) + || wasm_elem_is_declarative(module->table_segments[i].mode)) bh_bitmap_set_bit(module_inst->e->common.elem_dropped, i); } } From 9d8150efaee35240638a756ddd35b23f1376a4a1 Mon Sep 17 00:00:00 2001 From: Dylan Johnston <18252447+dpjohnst@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:31:55 +1100 Subject: [PATCH 020/431] Fix WASI Path Mapping Processing (#3923) Filesystem paths can be mapped from the host path to a guest path using the format `::`. Previously `strtok` was used to find the `::` delimiter. Unfortunately `strtok` processes each delimiter character individually. This meant that the code was ~equivalent to `strtok(mapping_copy, ":")` which breaks with Windows-style paths (E.g. `C:\my_path\`). To fix this `strstr` is used to search for the exact delimiter. --- core/iwasm/common/wasm_runtime_common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index fb16aa0f3c..26aab96642 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -3631,8 +3631,14 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst, bh_memcpy_s(mapping_copy, max_len, map_dir_list[i], (uint32)(strlen(map_dir_list[i]) + 1)); - map_mapped = strtok(mapping_copy, "::"); - map_host = strtok(NULL, "::"); + + const char *delim = "::"; + char *delim_pos = strstr(mapping_copy, delim); + if (delim_pos) { + *delim_pos = '\0'; + map_mapped = mapping_copy; + map_host = delim_pos + strlen(delim); + } if (!map_mapped || !map_host) { if (error_buf) From dbdf3df60b8bc4fc81b46f7d53335e986b2cfb15 Mon Sep 17 00:00:00 2001 From: James Ring Date: Sat, 23 Nov 2024 19:32:34 -0800 Subject: [PATCH 021/431] Use plain assignment rather than bh_memcpy_s (#3924) --- core/iwasm/interpreter/wasm_runtime.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index f9378aac98..c3f35916cd 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -1208,9 +1208,8 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst, /* The linked global instance has been initialized, we just need to copy the value. */ - bh_memcpy_s(&(global->initial_value), sizeof(WASMValue), - &(global_import->import_global_linked->init_expr.u), - sizeof(WASMValue)); + global->initial_value = + global_import->import_global_linked->init_expr.u; } else #endif From b0c6d5c23a243cb51f2672f552882de24305f42b Mon Sep 17 00:00:00 2001 From: WenLY1 <130950131+WenLY1@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:34:38 +0800 Subject: [PATCH 022/431] add testcases for shared heap and fix POP_MEM_OFFSET of memory64 (#3916) - add testcases for shared_heap - fix POP_MEM_OFFSET and POP_TBL_ELEM_IDX of memory64 Signed-off-by: wenlingyun1 --- core/iwasm/interpreter/wasm_interp_classic.c | 4 +- tests/unit/shared-heap/CMakeLists.txt | 2 +- tests/unit/shared-heap/shared_heap_test.cc | 132 +++++++++++++++--- .../unit/shared-heap/wasm-apps/CMakeLists.txt | 35 ++++- tests/unit/shared-heap/wasm-apps/test.c | 14 +- .../shared-heap/wasm-apps/test_addr_conv.c | 32 +++++ 6 files changed, 197 insertions(+), 22 deletions(-) create mode 100644 tests/unit/shared-heap/wasm-apps/test_addr_conv.c diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 7041fd89c0..834311f7ea 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -593,8 +593,8 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame) #endif #if WASM_ENABLE_MEMORY64 != 0 -#define POP_MEM_OFFSET() (is_memory64 ? POP_I64() : POP_I32()) -#define POP_TBL_ELEM_IDX() (is_table64 ? POP_I64() : POP_I32()) +#define POP_MEM_OFFSET() (is_memory64 ? POP_I64() : (uint32)POP_I32()) +#define POP_TBL_ELEM_IDX() (is_table64 ? POP_I64() : (uint32)POP_I32()) #else #define POP_MEM_OFFSET() POP_I32() #define POP_TBL_ELEM_IDX() POP_I32() diff --git a/tests/unit/shared-heap/CMakeLists.txt b/tests/unit/shared-heap/CMakeLists.txt index 6baf420f89..2b06c537f8 100644 --- a/tests/unit/shared-heap/CMakeLists.txt +++ b/tests/unit/shared-heap/CMakeLists.txt @@ -8,7 +8,7 @@ project(test-shared-heap) add_definitions(-DRUN_ON_LINUX) set(WAMR_BUILD_APP_FRAMEWORK 0) -set(WAMR_BUILD_AOT 0) +set(WAMR_BUILD_AOT 1) set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_FAST_INTERP 1) set(WAMR_BUILD_JIT 0) diff --git a/tests/unit/shared-heap/shared_heap_test.cc b/tests/unit/shared-heap/shared_heap_test.cc index 5e45d31119..deb4bbb388 100644 --- a/tests/unit/shared-heap/shared_heap_test.cc +++ b/tests/unit/shared-heap/shared_heap_test.cc @@ -92,37 +92,28 @@ destroy_module_env(struct ret_env module_env) } } -TEST_F(shared_heap_test, test_shared_heap) +static void test_shared_heap(WASMSharedHeap *shared_heap, const char *file, const char *func_name, uint32 argc, uint32 argv[]) { struct ret_env tmp_module_env; WASMFunctionInstanceCommon *func_test = nullptr; bool ret = false; - uint32 argv[1] = { 65535 }; const char *exception = nullptr; - SharedHeapInitArgs args; - WASMSharedHeap *shared_heap = nullptr; - args.size = 1024; - shared_heap = wasm_runtime_create_shared_heap(&args); - tmp_module_env = load_wasm((char *)"test.wasm", 0); + tmp_module_env = load_wasm((char *)file, 0); - if (!shared_heap) { - printf("Failed to create shared heap\n"); - goto test_failed; - } if (!wasm_runtime_attach_shared_heap(tmp_module_env.wasm_module_inst, shared_heap)) { printf("Failed to attach shared heap\n"); goto test_failed; } - func_test = wasm_runtime_lookup_function( - tmp_module_env.wasm_module_inst, "test"); + func_test = wasm_runtime_lookup_function(tmp_module_env.wasm_module_inst, + func_name); if (!func_test) { printf("\nFailed to wasm_runtime_lookup_function!\n"); goto test_failed; } ret = - wasm_runtime_call_wasm(tmp_module_env.exec_env, func_test, 1, argv); + wasm_runtime_call_wasm(tmp_module_env.exec_env, func_test, argc, argv); if (!ret) { printf("\nFailed to wasm_runtime_call_wasm!\n"); const char *s = wasm_runtime_get_exception(tmp_module_env.wasm_module_inst); @@ -131,12 +122,119 @@ TEST_F(shared_heap_test, test_shared_heap) } wasm_runtime_detach_shared_heap(tmp_module_env.wasm_module_inst); - - EXPECT_EQ(10, argv[0]); - destroy_module_env(tmp_module_env); return; test_failed: destroy_module_env(tmp_module_env); EXPECT_EQ(1, 0); } + +TEST_F(shared_heap_test, test_shared_heap_basic) +{ + SharedHeapInitArgs args; + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[1] = { 0 }; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + + if (!shared_heap) { + printf("Failed to create shared heap\n"); + EXPECT_EQ(1, 0); + } + + // test wasm + test_shared_heap(shared_heap, "test.wasm", "test", 1, argv); + EXPECT_EQ(10, argv[0]); + + // test aot + test_shared_heap(shared_heap, "test.aot", "test", 1, argv); + EXPECT_EQ(10, argv[0]); + +} + +TEST_F(shared_heap_test, test_shared_heap_malloc_fail) +{ + SharedHeapInitArgs args; + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[1] = { 0 }; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + + if (!shared_heap) { + printf("Failed to create shared heap\n"); + EXPECT_EQ(1, 0); + } + + // test wasm + test_shared_heap(shared_heap, "test.wasm", "test_malloc_fail", 1, argv); + EXPECT_EQ(1, argv[0]); + + // test aot + test_shared_heap(shared_heap, "test.aot", "test_malloc_fail", 1, argv); + EXPECT_EQ(1, argv[0]); +} + +#ifndef native_function +#define native_function(func_name, signature) \ + { #func_name, (void *)glue_##func_name, signature, NULL } + +#endif +#ifndef nitems +#define nitems(_a) (sizeof(_a) / sizeof(0 [(_a)])) +#endif /* nitems */ +uintptr_t glue_test_addr_conv(wasm_exec_env_t env, uintptr_t addr) +{ + wasm_module_inst_t module_inst = get_module_inst(env); + uintptr_t ret; + void *native_addr = (void *)addr; + uintptr_t app_addr = addr_native_to_app(native_addr); + + native_addr = addr_app_to_native(app_addr); + if (native_addr != (void *)addr) + { + EXPECT_EQ(1, 0); + } + return app_addr; +} + +static NativeSymbol g_test_native_symbols[] = +{ + native_function(test_addr_conv,"(*)i"), +}; + +TEST_F(shared_heap_test, test_addr_conv) +{ + SharedHeapInitArgs args; + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[1] = { 0 }; + struct ret_env tmp_module_env; + WASMFunctionInstanceCommon *func_test = nullptr; + bool ret = false; + const char *exception = nullptr; + wasm_module_inst_t module_inst = tmp_module_env.wasm_module_inst; + + ret = wasm_native_register_natives("env", g_test_native_symbols, + nitems(g_test_native_symbols)); + if (!ret) + { + EXPECT_EQ(1, 0); + return; + } + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + printf("Failed to create shared heap\n"); + EXPECT_EQ(1, 0); + } + + // test wasm + test_shared_heap(shared_heap, "test_addr_conv.wasm", "test", 1, argv); + EXPECT_EQ(1, argv[0]); + + // test aot + test_shared_heap(shared_heap, "test_addr_conv.aot", "test", 1, argv); + EXPECT_EQ(1, argv[0]); +} diff --git a/tests/unit/shared-heap/wasm-apps/CMakeLists.txt b/tests/unit/shared-heap/wasm-apps/CMakeLists.txt index 3627a2c144..097f66ae5d 100644 --- a/tests/unit/shared-heap/wasm-apps/CMakeLists.txt +++ b/tests/unit/shared-heap/wasm-apps/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.14) project(wasm-apps) set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) +set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler/build) set(CMAKE_SYSTEM_PROCESSOR wasm32) set(CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot) @@ -36,4 +37,36 @@ add_custom_command(TARGET test.wasm POST_BUILD ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_BINARY_DIR}/../ COMMENT "Copy test.wasm to the same directory of google test" - ) \ No newline at end of file + ) + +add_custom_command(TARGET test.wasm POST_BUILD + COMMAND ${WAMRC_ROOT_DIR}/wamrc --opt-level=0 --enable-shared-heap --bounds-checks=1 + -o + test.aot + test.wasm + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/test.aot + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMENT "Copy test.aot to the same directory of google test" + ) + +add_executable(test_addr_conv.wasm test_addr_conv.c) +target_link_libraries(test.wasm) + +add_custom_command(TARGET test_addr_conv.wasm POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.wasm + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMENT "Copy test_addr_conv.wasm to the same directory of google test" + ) + +add_custom_command(TARGET test_addr_conv.wasm POST_BUILD + COMMAND ${WAMRC_ROOT_DIR}/wamrc --opt-level=0 --enable-shared-heap --bounds-checks=1 + -o + test_addr_conv.aot + test_addr_conv.wasm + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.aot + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMENT "Copy test_addr_conv.aot to the same directory of google test" + ) diff --git a/tests/unit/shared-heap/wasm-apps/test.c b/tests/unit/shared-heap/wasm-apps/test.c index b83ee64ffa..bd0df19c20 100644 --- a/tests/unit/shared-heap/wasm-apps/test.c +++ b/tests/unit/shared-heap/wasm-apps/test.c @@ -13,10 +13,22 @@ shared_heap_free(void *offset); int test() { - int *ptr = (int *)shared_heap_malloc(10); + int *ptr = (int *)shared_heap_malloc(4); *ptr = 10; int a = *ptr; shared_heap_free(ptr); return a; } + +int +test_malloc_fail() +{ + int *ptr = (int *)shared_heap_malloc(8192); + + if (ptr == NULL) { + return 1; + } + shared_heap_free(ptr); + return 0; +} diff --git a/tests/unit/shared-heap/wasm-apps/test_addr_conv.c b/tests/unit/shared-heap/wasm-apps/test_addr_conv.c new file mode 100644 index 0000000000..f91764c84c --- /dev/null +++ b/tests/unit/shared-heap/wasm-apps/test_addr_conv.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Xiaomi Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +extern void * +shared_heap_malloc(int size); +extern void +shared_heap_free(void *offset); +extern void * +test_addr_conv(void *ptr); + +int +test() +{ + int *ptr = NULL; + int *ptr2 = NULL; + + ptr = (int *)shared_heap_malloc(4); + + if (ptr == NULL) { + return 0; + } + ptr2 = test_addr_conv(ptr); + if (ptr2 != ptr) { + return 0; + } + shared_heap_free(ptr); + return 1; +} From 1d111a38d68abf71f1fa513ee21927e764aeec38 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:08:51 +0800 Subject: [PATCH 023/431] Fix loader small bug (#3928) --- core/iwasm/interpreter/wasm_loader.c | 7 ++++++- core/iwasm/interpreter/wasm_mini_loader.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 4184562108..79ed996d87 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -9855,7 +9855,12 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, else { loader_ctx->frame_offset = frame_offset; loader_ctx->dynamic_offset = dynamic_offset; - PUSH_OFFSET_TYPE(return_types[i]); + if (!(wasm_loader_push_frame_offset( + loader_ctx, return_types[i], disable_emit, + operand_offset, error_buf, error_buf_size))) { + wasm_runtime_free(emit_data); + goto fail; + } wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); loader_ctx->frame_offset = frame_offset_org; loader_ctx->dynamic_offset = dynamic_offset_org; diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index a1fb3102fa..4dad55523b 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -5561,7 +5561,12 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, else { loader_ctx->frame_offset = frame_offset; loader_ctx->dynamic_offset = dynamic_offset; - PUSH_OFFSET_TYPE(return_types[i]); + if (!(wasm_loader_push_frame_offset( + loader_ctx, return_types[i], disable_emit, + operand_offset, error_buf, error_buf_size))) { + wasm_runtime_free(emit_data); + goto fail; + } wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); loader_ctx->frame_offset = frame_offset_org; loader_ctx->dynamic_offset = dynamic_offset_org; From 7b553cd420e9cd1f93817d054345f8733a681295 Mon Sep 17 00:00:00 2001 From: Maks Litskevich Date: Wed, 27 Nov 2024 14:06:07 +0300 Subject: [PATCH 024/431] Enable ref types by default (#3894) --- CMakeLists.txt | 4 ++-- doc/build_wamr.md | 2 +- product-mini/platforms/linux/CMakeLists.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40658e9ac7..3efd6aa827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,8 +113,8 @@ if (NOT DEFINED WAMR_BUILD_SIMD) endif () if (NOT DEFINED WAMR_BUILD_REF_TYPES) - # Disable reference types by default - set (WAMR_BUILD_REF_TYPES 0) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) endif () set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 4537ee0841..abf663177d 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -223,7 +223,7 @@ Currently we only profile the memory consumption of module, module_instance and > See [basic sample](../samples/basic/src/main.c) for a usage example. #### **Enable reference types feature** -- **WAMR_BUILD_REF_TYPES**=1/0, default to disable if not set +- **WAMR_BUILD_REF_TYPES**=1/0, default to enable if not set #### **Exclude WAMR application entry functions** - **WAMR_DISABLE_APP_ENTRY**=1/0, default to disable if not set diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index 2e37b75f92..321c4a955b 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -108,8 +108,8 @@ if (NOT DEFINED WAMR_BUILD_SIMD) endif () if (NOT DEFINED WAMR_BUILD_REF_TYPES) - # Disable reference types by default - set (WAMR_BUILD_REF_TYPES 0) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) endif () if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP) From 27d96aac02abad895793b7a0d1aa20707ad54566 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 27 Nov 2024 19:06:22 +0800 Subject: [PATCH 025/431] Update README.md to clarify Windows toolchain support and ESP-IDF reference (#3917) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d89d0cd17f..05368b9295 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ The WAMR VMcore supports the following architectures: - XTENSA, MIPS, ARC The following platforms are supported, click each link below for how to build iwasm on that platform. Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform. -- [Linux](./product-mini/README.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos), [Android](./product-mini/README.md#android), [Windows](./product-mini/README.md#windows), [Windows (MinGW)](./product-mini/README.md#mingw) -- [Zephyr](./product-mini/README.md#zephyr), [AliOS-Things](./product-mini/README.md#alios-things), [VxWorks](./product-mini/README.md#vxworks), [NuttX](./product-mini/README.md#nuttx), [RT-Thread](./product-mini/README.md#RT-Thread), [ESP-IDF](./product-mini/README.md#esp-idf) +- [Linux](./product-mini/README.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos), [Android](./product-mini/README.md#android), [Windows](./product-mini/README.md#windows), [Windows (MinGW, MSVC)](./product-mini/README.md#mingw) +- [Zephyr](./product-mini/README.md#zephyr), [AliOS-Things](./product-mini/README.md#alios-things), [VxWorks](./product-mini/README.md#vxworks), [NuttX](./product-mini/README.md#nuttx), [RT-Thread](./product-mini/README.md#RT-Thread), [ESP-IDF(FreeRTOS)](./product-mini/README.md#esp-idf) ## Getting started From fd91b51cfb36345b7a3c4fd66771171dc865385d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:49:23 +0800 Subject: [PATCH 026/431] build(deps): bump github/codeql-action from 3.27.4 to 3.27.5 (#3931) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.4 to 3.27.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.4...v3.27.5) --- 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 c71f305aae..9ed8919c7e 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.27.4 + uses: github/codeql-action/init@v3.27.5 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.27.4 + uses: github/codeql-action/analyze@v3.27.5 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.27.4 + uses: github/codeql-action/upload-sarif@v3.27.5 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 1d5baa6b14..f2aa485eaa 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@a1695c562bbfa68dc5ab58c9b5e9f616b52bf5be # v2.2.4 + uses: github/codeql-action/upload-sarif@3d3d628990a5f99229dd9fa1821cc5a4f31b613b # v2.2.4 with: sarif_file: results.sarif From 8698d22e6738a278eb9639ba9c8860456550771f Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:49:55 +0800 Subject: [PATCH 027/431] add thread cpu time for zephyr (#3937) --- core/shared/platform/zephyr/zephyr_time.c | 15 +++++++++++++-- product-mini/platforms/zephyr/simple/prj.conf | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/shared/platform/zephyr/zephyr_time.c b/core/shared/platform/zephyr/zephyr_time.c index 78bc3e0761..59b720e414 100644 --- a/core/shared/platform/zephyr/zephyr_time.c +++ b/core/shared/platform/zephyr/zephyr_time.c @@ -14,6 +14,17 @@ os_time_get_boot_us() uint64 os_time_thread_cputime_us(void) { - /* FIXME if u know the right api */ - return os_time_get_boot_us(); + k_tid_t tid; + struct k_thread_runtime_stats stats; + uint32 clock_freq; + uint64 cpu_cycles, time_in_us = 0; + + tid = k_current_get(); + if (k_thread_runtime_stats_get(tid, &stats) == 0) { + cpu_cycles = stats.execution_cycles; + clock_freq = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC; + time_in_us = (cpu_cycles * 1000000) / clock_freq; + } + + return time_in_us; } diff --git a/product-mini/platforms/zephyr/simple/prj.conf b/product-mini/platforms/zephyr/simple/prj.conf index c269b8ab42..8ab3c52f8c 100644 --- a/product-mini/platforms/zephyr/simple/prj.conf +++ b/product-mini/platforms/zephyr/simple/prj.conf @@ -5,3 +5,4 @@ CONFIG_STACK_SENTINEL=y CONFIG_PRINTK=y CONFIG_LOG=y CONFIG_LOG_BUFFER_SIZE=4096 +CONFIG_THREAD_RUNTIME_STATS=y From e09613c722ca45b2f2d659024d109786f212182b Mon Sep 17 00:00:00 2001 From: James Ring Date: Wed, 27 Nov 2024 19:50:16 -0800 Subject: [PATCH 028/431] support WASM_FUNCREF return type in argv_to_results (#3936) --- core/iwasm/common/wasm_c_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 0c5e37eabb..500f99dc8b 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -3330,6 +3330,7 @@ argv_to_results(const uint32 *argv, const wasm_valtype_vec_t *result_defs, break; #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 case WASM_EXTERNREF: + case WASM_FUNCREF: result->of.ref = (struct wasm_ref_t *)(*(uintptr_t *)argv); argv += sizeof(uintptr_t) / sizeof(uint32); break; From 838dd81e682249fbd2d7ee16d6999dafb87481b9 Mon Sep 17 00:00:00 2001 From: James Ring Date: Wed, 27 Nov 2024 19:50:44 -0800 Subject: [PATCH 029/431] don't return an uninitialized trap if argv_to_results fails (#3935) Currently, if argv_to_results fails (e.g. because an unsupported type is encountered), an non-null trap with an uninitialized message is returned. --- core/iwasm/common/wasm_c_api.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 500f99dc8b..d5c45a4413 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -3442,6 +3442,8 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, if (result_count) { if (!argv_to_results(argv, wasm_functype_results(func->type), results)) { + wasm_runtime_set_exception(func->inst_comm_rt, + "argv_to_results failed"); goto failed; } results->num_elems = result_count; From 739efd78e9bd601b59a3688506396bc7968fbbf2 Mon Sep 17 00:00:00 2001 From: Dylan Johnston <18252447+dpjohnst@users.noreply.github.com> Date: Sun, 1 Dec 2024 23:40:43 +1100 Subject: [PATCH 030/431] Fix incorrect assignment in win_file.c (#3939) win_error should be compared to ERROR_INVALID_HANDLE but was instead being assigned the value. --- core/shared/platform/windows/win_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/shared/platform/windows/win_file.c b/core/shared/platform/windows/win_file.c index 408d0d00c2..770c5c741b 100644 --- a/core/shared/platform/windows/win_file.c +++ b/core/shared/platform/windows/win_file.c @@ -1758,7 +1758,7 @@ os_closedir(os_dir_stream dir_stream) if (!success) { DWORD win_error = GetLastError(); - if (win_error = ERROR_INVALID_HANDLE) + if (win_error == ERROR_INVALID_HANDLE) BH_FREE(dir_stream); return convert_windows_error_code(win_error); } From aabe83074ebfce6be5332765ed71d093975d8a24 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:39:53 +0800 Subject: [PATCH 031/431] Improvements for platform thread APIs on Windows and Zephyr (#3941) * improvements for os_thread_join on Windows and Zephyr --- core/shared/platform/windows/win_thread.c | 72 +++++++++++++++++++-- core/shared/platform/zephyr/zephyr_thread.c | 14 ++-- core/shared/utils/bh_atomic.h | 3 +- 3 files changed, 78 insertions(+), 11 deletions(-) diff --git a/core/shared/platform/windows/win_thread.c b/core/shared/platform/windows/win_thread.c index f37250fa4e..438e160405 100644 --- a/core/shared/platform/windows/win_thread.c +++ b/core/shared/platform/windows/win_thread.c @@ -60,6 +60,63 @@ static DWORD thread_data_key; static void(WINAPI *GetCurrentThreadStackLimits_Kernel32)(PULONG_PTR, PULONG_PTR) = NULL; +static void +thread_data_list_add(os_thread_data *thread_data) +{ + os_mutex_lock(&thread_data_list_lock); + /* If already in list, just return */ + os_thread_data *p = &supervisor_thread_data; + while (p) { + if (p == thread_data) { + os_mutex_unlock(&thread_data_list_lock); + return; + } + p = p->next; + } + thread_data->next = supervisor_thread_data.next; + supervisor_thread_data.next = thread_data; + os_mutex_unlock(&thread_data_list_lock); +} + +static void +thread_data_list_remove(os_thread_data *thread_data) +{ + os_mutex_lock(&thread_data_list_lock); + /* Search and remove it from list */ + os_thread_data *p = &supervisor_thread_data; + while (p && p->next != thread_data) + p = p->next; + + if (p && p->next) { + bh_assert(p->next == thread_data); + p->next = p->next->next; + /* Release the resources in thread_data */ + os_cond_destroy(&thread_data->wait_cond); + os_mutex_destroy(&thread_data->wait_lock); + os_sem_destroy(&thread_data->wait_node.sem); + BH_FREE(thread_data); + } + os_mutex_unlock(&thread_data_list_lock); +} + +static os_thread_data * +thread_data_list_lookup(korp_tid tid) +{ + os_thread_data *thread_data = (os_thread_data *)tid; + os_mutex_lock(&thread_data_list_lock); + os_thread_data *p = supervisor_thread_data.next; + while (p) { + if (p == thread_data) { + /* Found */ + os_mutex_unlock(&thread_data_list_lock); + return p; + } + p = p->next; + } + os_mutex_unlock(&thread_data_list_lock); + return NULL; +} + int os_sem_init(korp_sem *sem); int @@ -254,10 +311,7 @@ os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start, } /* Add thread data into thread data list */ - os_mutex_lock(&thread_data_list_lock); - thread_data->next = supervisor_thread_data.next; - supervisor_thread_data.next = thread_data; - os_mutex_unlock(&thread_data_list_lock); + thread_data_list_add(thread_data); /* Wait for the thread routine to set thread_data's tid and add thread_data to thread data list */ @@ -302,8 +356,12 @@ os_thread_join(korp_tid thread, void **p_retval) curr_thread_data->wait_node.next = NULL; /* Get thread data of thread to join */ - thread_data = (os_thread_data *)thread; - bh_assert(thread_data); + thread_data = thread_data_list_lookup(thread); + + if (thread_data == NULL) { + os_printf("Can't join thread %p, it does not exist", thread); + return BHT_ERROR; + } os_mutex_lock(&thread_data->wait_lock); @@ -312,6 +370,7 @@ os_thread_join(korp_tid thread, void **p_retval) if (p_retval) *p_retval = thread_data->thread_retval; os_mutex_unlock(&thread_data->wait_lock); + thread_data_list_remove(thread_data); return BHT_OK; } @@ -332,6 +391,7 @@ os_thread_join(korp_tid thread, void **p_retval) os_sem_wait(&curr_thread_data->wait_node.sem); if (p_retval) *p_retval = curr_thread_data->wait_node.retval; + thread_data_list_remove(thread_data); return BHT_OK; } diff --git a/core/shared/platform/zephyr/zephyr_thread.c b/core/shared/platform/zephyr/zephyr_thread.c index 628a842d62..31aaad7a93 100644 --- a/core/shared/platform/zephyr/zephyr_thread.c +++ b/core/shared/platform/zephyr/zephyr_thread.c @@ -393,6 +393,16 @@ os_thread_join(korp_tid thread, void **value_ptr) os_thread_data *thread_data; os_thread_wait_node *node; + /* Get thread data */ + thread_data = thread_data_list_lookup(thread); + + if (thread_data == NULL) { + os_printf( + "Can't join thread %p, probably already exited or does not exist", + thread); + return BHT_OK; + } + /* Create wait node and append it to wait list */ if (!(node = BH_MALLOC(sizeof(os_thread_wait_node)))) return BHT_ERROR; @@ -400,10 +410,6 @@ os_thread_join(korp_tid thread, void **value_ptr) sem_init(&node->sem, 0, 1); node->next = NULL; - /* Get thread data */ - thread_data = thread_data_list_lookup(thread); - bh_assert(thread_data != NULL); - mutex_lock(&thread_data->wait_list_lock, K_FOREVER); if (!thread_data->thread_wait_list) thread_data->thread_wait_list = node; diff --git a/core/shared/utils/bh_atomic.h b/core/shared/utils/bh_atomic.h index 5148497f8c..57cb4d1c91 100644 --- a/core/shared/utils/bh_atomic.h +++ b/core/shared/utils/bh_atomic.h @@ -114,7 +114,8 @@ typedef uint16 bh_atomic_16_t; #endif /* On some 32-bit platform, disable 64-bit atomic operations, otherwise - * undefined reference to `__atomic_load_8' */ + * undefined reference to `__atomic_load_8', if on Zephyr, can add board related + * macro in autoconf.h to control */ #ifndef WASM_UINT64_IS_ATOMIC #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) \ && !defined(__OpenBSD__) && (defined(__riscv) || defined(__arm__)) \ From c32a6ceae1114d177b493ecaf949213ac29db910 Mon Sep 17 00:00:00 2001 From: kk Date: Fri, 6 Dec 2024 14:54:37 +0800 Subject: [PATCH 032/431] Refactor SConscript and add file checks in iwasm.c (#3945) --- core/iwasm/common/SConscript | 11 ++++------- product-mini/platforms/rt-thread/iwasm.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/iwasm/common/SConscript b/core/iwasm/common/SConscript index 0a55f244b9..eb69744e90 100644 --- a/core/iwasm/common/SConscript +++ b/core/iwasm/common/SConscript @@ -13,13 +13,10 @@ cwd = GetCurrentDir() src = Glob('*.c') -if rtconfig.ARCH == 'arm': - if re.match('^cortex-m.*', rtconfig.CPU): - src += ['arch/invokeNative_thumb.s'] - elif re.match('^cortex-a.*', rtconfig.CPU): - src += ['arch/invokeNative_arm.s'] -elif rtconfig.ARCH == 'ia32': - src += ['arch/invokeNative_ia32.s'] +if rtconfig.ARCH == 'arm' and re.match('^cortex-m.*', rtconfig.CPU): + src += ['arch/invokeNative_thumb.s'] +else: + src.append(f"arch/invokeNative_{rtconfig.ARCH}.s") CPPPATH = [cwd, cwd + '/../include'] diff --git a/product-mini/platforms/rt-thread/iwasm.c b/product-mini/platforms/rt-thread/iwasm.c index 7d15a041d0..f8932bdec3 100644 --- a/product-mini/platforms/rt-thread/iwasm.c +++ b/product-mini/platforms/rt-thread/iwasm.c @@ -192,6 +192,21 @@ my_read_file_to_buffer(char *filename, rt_uint32_t *size) { struct stat f_stat; + if (!filename || !size) { + rt_set_errno(-EINVAL); + return RT_NULL; + } + + if (stat(filename, &f_stat) != 0) { + rt_set_errno(errno); + return RT_NULL; + } + + if (f_stat.st_size <= 0) { + rt_set_errno(-EINVAL); + return RT_NULL; + } + rt_uint8_t *buff = rt_malloc(f_stat.st_size); *size = 0; if (!buff) { From f665e7b739c83506bc44d7a08a26561a3f93a6ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:39:04 +0000 Subject: [PATCH 033/431] build(deps): bump github/codeql-action from 3.27.5 to 3.27.6 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.5 to 3.27.6. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.5...v3.27.6) --- 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 9ed8919c7e..88f13cc8b9 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.27.5 + uses: github/codeql-action/init@v3.27.6 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.27.5 + uses: github/codeql-action/analyze@v3.27.6 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.27.5 + uses: github/codeql-action/upload-sarif@v3.27.6 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 f2aa485eaa..2d605f6c97 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@3d3d628990a5f99229dd9fa1821cc5a4f31b613b # v2.2.4 + uses: github/codeql-action/upload-sarif@6f9e628e6f9a18c785dd746325ba455111df1b67 # v2.2.4 with: sarif_file: results.sarif From 591b74057101fbb8ae91dc9ecc14a41684c2f325 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 10 Dec 2024 20:26:14 +0800 Subject: [PATCH 034/431] Consume the placeholders that were put when emitting table info (#3940) --- core/iwasm/aot/aot_loader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index dd26bbee5c..239e328bd4 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1333,7 +1333,12 @@ load_import_table_list(const uint8 **p_buf, const uint8 *buf_end, if (wasm_is_type_multi_byte_type(import_table->table_type.elem_type)) { read_uint8(buf, buf_end, ref_type.ref_ht_common.nullable); } + else #endif + { + /* Skip 1 byte */ + buf += 1; + } read_uint32(buf, buf_end, import_table->table_type.init_size); read_uint32(buf, buf_end, import_table->table_type.max_size); #if WASM_ENABLE_GC != 0 @@ -1393,7 +1398,12 @@ load_table_list(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, if (wasm_is_type_multi_byte_type(table->table_type.elem_type)) { read_uint8(buf, buf_end, ref_type.ref_ht_common.nullable); } + else #endif + { + /* Skip 1 byte */ + buf += 1; + } read_uint32(buf, buf_end, table->table_type.init_size); read_uint32(buf, buf_end, table->table_type.max_size); #if WASM_ENABLE_GC != 0 @@ -1481,7 +1491,7 @@ load_table_init_data_list(const uint8 **p_buf, const uint8 *buf_end, else #endif { - /* Skip 8 byte for ref type info */ + /* Skip 8 byte(2+2+4) for ref type info */ buf += 8; } From bebdd4ad174a49005b62e4074e71cd32b05640e8 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 10 Dec 2024 20:26:32 +0800 Subject: [PATCH 035/431] Fix aot table instantiate (#3946) --- core/iwasm/aot/aot_runtime.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 8a33a72716..0f7b5d3d9a 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -689,20 +689,23 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module, tbl_inst->cur_size = import_table->table_type.init_size; tbl_inst->max_size = aot_get_imp_tbl_data_slots(import_table, false); - tbl_inst->elem_type = module->tables[i].table_type.elem_type; + tbl_inst->elem_type = import_table->table_type.elem_type; + tbl_inst->is_table64 = + import_table->table_type.flags & TABLE64_FLAG; #if WASM_ENABLE_GC != 0 tbl_inst->elem_ref_type.elem_ref_type = - module->tables[i].table_type.elem_ref_type; + import_table->table_type.elem_ref_type; #endif } else { AOTTable *table = module->tables + (i - module->import_table_count); tbl_inst->cur_size = table->table_type.init_size; tbl_inst->max_size = aot_get_tbl_data_slots(table, false); - tbl_inst->elem_type = module->tables[i].table_type.elem_type; + tbl_inst->elem_type = table->table_type.elem_type; + tbl_inst->is_table64 = table->table_type.flags & TABLE64_FLAG; #if WASM_ENABLE_GC != 0 tbl_inst->elem_ref_type.elem_ref_type = - module->tables[i].table_type.elem_ref_type; + table->table_type.elem_ref_type; #endif } From 9563909d6c104906f4a8ad4f3be08a4241d781a6 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:33:46 +0800 Subject: [PATCH 036/431] set alignment 4 when loading multi return value (#3955) set alignment 4 when loading multi return value for all call opcodes --- core/iwasm/compilation/aot_emit_function.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/iwasm/compilation/aot_emit_function.c b/core/iwasm/compilation/aot_emit_function.c index 49b1ac1cb4..d22c1d5dd2 100644 --- a/core/iwasm/compilation/aot_emit_function.c +++ b/core/iwasm/compilation/aot_emit_function.c @@ -1832,6 +1832,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build load failed."); goto fail; } + LLVMSetAlignment(ext_ret, 4); PUSH(ext_ret, ext_ret_types[i]); } } @@ -2068,6 +2069,7 @@ call_aot_call_indirect_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build load failed."); return false; } + LLVMSetAlignment(value_rets[i], 4); cell_num += wasm_value_type_cell_num_internal(wasm_ret_types[i], comp_ctx->pointer_size); } @@ -2699,6 +2701,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build load failed."); goto fail; } + LLVMSetAlignment(ext_ret, 4); LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1); } } @@ -3130,6 +3133,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build load failed."); goto fail; } + LLVMSetAlignment(ext_ret, 4); LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1); } } @@ -3205,6 +3209,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build load failed."); goto fail; } + LLVMSetAlignment(ext_ret, 4); LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1); } } From 296c3cc69ddf5afe21e3a8cb7cb6407f93064212 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo <90845888+midokura-xavi92@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:49:13 +0100 Subject: [PATCH 037/431] wasm_export.h: Use "default" visibility for gcc and clang (#3957) Since the top-level CMakelists.txt is appending `-fvisibility=hidden` to the compile options, no public symbols are exported by default. This forbids users from linking against the shared library. Using `gcc/clang` attributes [1], it is possible to override the definition for `WASM_RUNTIME_API_EXTERN` so that only required symbols are correctly exported. [1]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes --- core/iwasm/include/wasm_export.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index aa6cfaae75..273657246d 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -23,6 +23,8 @@ #else #define WASM_RUNTIME_API_EXTERN __declspec(dllimport) #endif +#elif defined(__GNUC__) || defined(__clang__) +#define WASM_RUNTIME_API_EXTERN __attribute__((visibility("default"))) #else #define WASM_RUNTIME_API_EXTERN #endif From 09c2abde4aa2398eab024459ddc9ec58fbfefa9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:05:44 +0800 Subject: [PATCH 038/431] build(deps): Bump github/codeql-action from 3.27.6 to 3.27.9 (#3960) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.6 to 3.27.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.6...v3.27.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 88f13cc8b9..697aba4b0a 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.27.6 + uses: github/codeql-action/init@v3.27.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.27.6 + uses: github/codeql-action/analyze@v3.27.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.27.6 + uses: github/codeql-action/upload-sarif@v3.27.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 2d605f6c97..3fa3182929 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@6f9e628e6f9a18c785dd746325ba455111df1b67 # v2.2.4 + uses: github/codeql-action/upload-sarif@dd7559424621a6dd0b32ababe9e4b271a87f78d2 # v2.2.4 with: sarif_file: results.sarif From 932eb5d9e5be01e812d8783d60ce6984f39014be Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:26:34 +0800 Subject: [PATCH 039/431] Only access Zephyr thread stats info when it's available (#3962) --- core/shared/platform/zephyr/zephyr_time.c | 6 ++++++ product-mini/platforms/zephyr/simple/build_and_run.sh | 2 +- tests/fuzz/wasm-mutator-fuzz/portal/osv-scanner.toml | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/shared/platform/zephyr/zephyr_time.c b/core/shared/platform/zephyr/zephyr_time.c index 59b720e414..5b84057379 100644 --- a/core/shared/platform/zephyr/zephyr_time.c +++ b/core/shared/platform/zephyr/zephyr_time.c @@ -14,6 +14,9 @@ os_time_get_boot_us() uint64 os_time_thread_cputime_us(void) { + /* On certain boards, enabling userspace could impact the collection of + * thread runtime statistics */ +#ifdef CONFIG_THREAD_RUNTIME_STATS k_tid_t tid; struct k_thread_runtime_stats stats; uint32 clock_freq; @@ -27,4 +30,7 @@ os_time_thread_cputime_us(void) } return time_in_us; +#else + return os_time_get_boot_us(); +#endif } diff --git a/product-mini/platforms/zephyr/simple/build_and_run.sh b/product-mini/platforms/zephyr/simple/build_and_run.sh index 6b8fb4f872..bd89906d4a 100755 --- a/product-mini/platforms/zephyr/simple/build_and_run.sh +++ b/product-mini/platforms/zephyr/simple/build_and_run.sh @@ -38,7 +38,7 @@ TARGET=$1 case $TARGET in $X86_TARGET) - west build -b qemu_x86_nommu \ + west build -b qemu_x86_tiny \ . -p always -- \ -DWAMR_BUILD_TARGET=X86_32 west build -t run diff --git a/tests/fuzz/wasm-mutator-fuzz/portal/osv-scanner.toml b/tests/fuzz/wasm-mutator-fuzz/portal/osv-scanner.toml index 1eb55cd8df..b1b7145dec 100644 --- a/tests/fuzz/wasm-mutator-fuzz/portal/osv-scanner.toml +++ b/tests/fuzz/wasm-mutator-fuzz/portal/osv-scanner.toml @@ -50,3 +50,10 @@ name = "vite" ecosystem = "npm" ignore = true reason = "Development server not exposed to untrusted networks" + +# GHSA-mwcw-c2x4-8c55 +[[PackageOverrides]] +name = "nanoid" +ecosystem = "npm" +ignore = true +reason = "Accepted known vulnerabilities for testing purposes" From 9916813a342baba08965b79519938c54e85a9cf1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Dec 2024 17:49:25 +0900 Subject: [PATCH 040/431] top-level cmakefile: fix macOS build (#3968) At least fast-jit seems to require a bit new C++ standard. C++17 was chosen to match product-mini/platforms/darwin. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3efd6aa827..e5a1bf1c50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ endif() project (iwasm) +set(CMAKE_CXX_STANDARD 17) + set (CMAKE_VERBOSE_MAKEFILE OFF) if (NOT DEFINED WAMR_BUILD_PLATFORM) From 8d51a3c7a82405c76df26154b321465fa4c6cb07 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 19 Dec 2024 16:49:44 +0800 Subject: [PATCH 041/431] use a random secret key (#3971) --- tests/fuzz/wasm-mutator-fuzz/server/app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/server/app/main.py b/tests/fuzz/wasm-mutator-fuzz/server/app/main.py index d8a0955e27..620625dd33 100644 --- a/tests/fuzz/wasm-mutator-fuzz/server/app/main.py +++ b/tests/fuzz/wasm-mutator-fuzz/server/app/main.py @@ -56,7 +56,7 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -app.secret_key = "hwhefsewljfejrlesjfl" +app.secret_key = os.urandom(12).hex() db = SQLAlchemy(app) From f8f37c8ebbcd618f28d7373c21d76bfecd44a8e3 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 19 Dec 2024 16:51:20 +0800 Subject: [PATCH 042/431] [fuzzing] Enable instantiation (#3958) - Increase input seed size for wasm-tools to generate larger WebAssembly modules - Add instantiation in wasm mutator fuzz tests --- tests/fuzz/wasm-mutator-fuzz/README.md | 1 + tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh | 38 +++++++++---------- .../wasm-mutator-fuzz/wasm_mutator_fuzz.cc | 36 +++++++++++------- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/README.md b/tests/fuzz/wasm-mutator-fuzz/README.md index 0d21519a1c..acf210ae42 100644 --- a/tests/fuzz/wasm-mutator-fuzz/README.md +++ b/tests/fuzz/wasm-mutator-fuzz/README.md @@ -19,6 +19,7 @@ $ wasm-tools help 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) diff --git a/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh b/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh index 29d24dbd08..02ac831742 100755 --- a/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh +++ b/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh @@ -33,36 +33,36 @@ function try_generate_wasm() local try_i=0 until [[ -f $GENERATED_WASM_NAME ]]; do - head -c 100 /dev/urandom | wasm-tools smith $SMITH_OPTIONS -o $GENERATED_WASM_NAME >/dev/null 2>&1 + # Larger input seeds tend to generate larger WebAssembly modules. (256KB) + head -c 262144 /dev/urandom | wasm-tools smith $SMITH_OPTIONS -o $GENERATED_WASM_NAME >/dev/null 2>&1 try_i=$((try_i+1)) done printf -- "-- output ${GENERATED_WASM_NAME} in %d retries\n" $try_i } -# try_generate_wasm "--min-memories=1 --min-tables=1" "test_min.wasm" +WASM_SHAPE=" --allow-invalid-funcs true \ +--generate-custom-sections true \ +--min-funcs 5 \ +--max-instructions 1024 \ +--min-globals 10" + +WASM_MVP_FEATURES=" --bulk-memory-enabled true \ +--multi-value-enabled true \ +--reference-types-enabled true \ +--simd-enabled true \ +--tail-call-enabled true" for i in $(seq 1 $EXPECTED_NUM) do - # by default - try_generate_wasm "" test_$i.wasm - - # with different features # mvp - try_generate_wasm "--min-memories=1 --min-tables=1" test_min_$i.wasm - try_generate_wasm "--min-memories=1 --min-tables=1 --bulk-memory-enabled true" test_bulk_$i.wasm - try_generate_wasm "--min-memories=1 --min-tables=1 --reference-types-enabled true" test_ref_$i.wasm - try_generate_wasm "--min-memories=1 --min-tables=1 --multi-value-enabled true" test_multi_$i.wasm - try_generate_wasm "--min-memories=1 --min-tables=1 --simd-enabled true" test_simd_$i.wasm - try_generate_wasm "--min-memories=1 --min-tables=1 --tail-call-enabled true " test_tail_$i.wasm + try_generate_wasm "${WASM_SHAPE} ${WASM_MVP_FEATURES}" test_mvp_$i.wasm - # enable me when compiling iwasm with those features - #try_generate_wasm "--min-memories=1 --min-tables=1 --threads-enabled true" test_thread_$i.wasm - #try_generate_wasm "--min-memories=1 --min-tables=1 --memory64-enabled true" test_memory64_$i.wasm - #try_generate_wasm "--min-memories=1 --min-tables=1 --exceptions-enabled true" test_exception_$i.wasm - #try_generate_wasm "--min-memories=1 --min-tables=1 --gc-enabled true" test_gc_$i.wasm - # with custom-section - try_generate_wasm "--min-memories=1 --min-tables=1 --generate-custom-sections true" test_custom_$i.wasm + # other proposals + try_generate_wasm "${WASM_SHAPE} --exceptions-enabled true" test_exception_$i.wasm + try_generate_wasm "${WASM_SHAPE} --gc-enabled true" test_gc_$i.wasm + try_generate_wasm "${WASM_SHAPE} --memory64-enabled true" test_memory64_$i.wasm + try_generate_wasm "${WASM_SHAPE} --threads-enabled true" test_threads_$i.wasm done printf "Done\n" diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc index 0817e5bdd0..2d5a667039 100644 --- a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc +++ b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc @@ -13,31 +13,41 @@ using namespace std; -extern "C" WASMModuleCommon * -wasm_runtime_load(uint8 *buf, uint32 size, char *error_buf, - uint32 error_buf_size); - -extern "C" WASMModuleInstanceCommon * -wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size, - uint32 heap_size, char *error_buf, - uint32 error_buf_size); - extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { /* libfuzzer don't allow us to modify the given Data, so we copy the data * here */ std::vector myData(Data, Data + Size); + /* init runtime environment */ wasm_runtime_init(); + + char error_buf[128] = { 0 }; wasm_module_t module = - wasm_runtime_load((uint8_t *)myData.data(), Size, nullptr, 0); - if (module) { + wasm_runtime_load((uint8_t *)myData.data(), Size, error_buf, 120); + if (!module) { + std::cout << "[LOADING] " << error_buf << std::endl; + wasm_runtime_destroy(); + /* return SUCCESS because the failure has been handled */ + return 0; + } + + wasm_module_inst_t inst = wasm_runtime_instantiate( + module, 8 * 1024 * 1024, 16 * 1024 * 1024, error_buf, 120); + if (!inst) { + std::cout << "[INSTANTIATE] " << error_buf << std::endl; wasm_runtime_unload(module); + wasm_runtime_destroy(); + /* return SUCCESS because the failure has been handled */ + return 0; } - /* destroy runtime environment */ - wasm_runtime_destroy(); + std::cout << "PASS" << std::endl; + + wasm_runtime_deinstantiate(inst); + wasm_runtime_unload(module); + wasm_runtime_destroy(); return 0; /* Values other than 0 and -1 are reserved for future use. */ } From 9598611e3565094008137c027ccbac69c5f6d020 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo <90845888+midokura-xavi92@users.noreply.github.com> Date: Fri, 20 Dec 2024 06:05:50 +0100 Subject: [PATCH 043/431] CMakeLists.txt: Do not require C++ (#3956) By default, the project() CMake command defaults to C and C++. [1] Therefore, CMake might perform tests for both C and C++ compilers as part of the configuration phase. However, this has the consequence of the configuration phase to fail if the system does not have a C++ toolchain installed, even if C++ is not really used by the top-level project under the default settings. Some configurations might still require a C++ toolchain, so enable_language is selectively called under such circumstances. [1]: https://cmake.org/cmake/help/latest/command/project.html --- CMakeLists.txt | 2 +- core/iwasm/compilation/iwasm_compl.cmake | 1 + core/iwasm/fast-jit/iwasm_fast_jit.cmake | 1 + core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake | 1 + core/shared/platform/windows/shared_platform.cmake | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5a1bf1c50..2bd82fc83a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ if(ESP_PLATFORM) return() endif() -project (iwasm) +project (iwasm LANGUAGES C) set(CMAKE_CXX_STANDARD 17) diff --git a/core/iwasm/compilation/iwasm_compl.cmake b/core/iwasm/compilation/iwasm_compl.cmake index 4ec4603049..77925d62d8 100644 --- a/core/iwasm/compilation/iwasm_compl.cmake +++ b/core/iwasm/compilation/iwasm_compl.cmake @@ -1,6 +1,7 @@ set (IWASM_COMPL_DIR ${CMAKE_CURRENT_LIST_DIR}) include_directories(${IWASM_COMPL_DIR}) +enable_language(CXX) if (WAMR_BUILD_DEBUG_AOT EQUAL 1) file (GLOB_RECURSE source_all diff --git a/core/iwasm/fast-jit/iwasm_fast_jit.cmake b/core/iwasm/fast-jit/iwasm_fast_jit.cmake index cd880a34b2..c5012bd36c 100644 --- a/core/iwasm/fast-jit/iwasm_fast_jit.cmake +++ b/core/iwasm/fast-jit/iwasm_fast_jit.cmake @@ -9,6 +9,7 @@ if (WAMR_BUILD_FAST_JIT_DUMP EQUAL 1) endif () include_directories (${IWASM_FAST_JIT_DIR}) +enable_language(CXX) if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") include(FetchContent) diff --git a/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake b/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake index a903f0af1f..c6deab6fca 100644 --- a/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake +++ b/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake @@ -22,6 +22,7 @@ add_compile_definitions( # - tflite if(WAMR_BUILD_WASI_NN_TFLITE EQUAL 1) find_package(tensorflow_lite REQUIRED) + enable_language(CXX) add_library( wasi_nn_tflite diff --git a/core/shared/platform/windows/shared_platform.cmake b/core/shared/platform/windows/shared_platform.cmake index c2d74463fb..7a3331eff1 100644 --- a/core/shared/platform/windows/shared_platform.cmake +++ b/core/shared/platform/windows/shared_platform.cmake @@ -6,6 +6,7 @@ set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR}) add_definitions(-DBH_PLATFORM_WINDOWS) add_definitions(-DHAVE_STRUCT_TIMESPEC) add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) +enable_language(CXX) include_directories(${PLATFORM_SHARED_DIR}) include_directories(${PLATFORM_SHARED_DIR}/../include) From 4cda74ad85e9f18dce0790e86ec8aaef1f76ba5c Mon Sep 17 00:00:00 2001 From: Chris Woods <6069113+woodsmc@users.noreply.github.com> Date: Sun, 22 Dec 2024 05:48:43 -0500 Subject: [PATCH 044/431] add reference type support by default for darwin to support WASI-SDK-25 (#3978) --- product-mini/platforms/darwin/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index 865e516fca..12ed8052fe 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -91,6 +91,11 @@ if (NOT DEFINED WAMR_BUILD_SIMD) set (WAMR_BUILD_SIMD 1) endif () +if (NOT DEFINED WAMR_BUILD_REF_TYPES) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) +endif () + if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP) # Disable Debug feature by default set (WAMR_BUILD_DEBUG_INTERP 0) From 040e776162688c20fdd0dd2fea2491c5cdc26bf9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Dec 2024 14:38:48 +0900 Subject: [PATCH 045/431] top-level cmake: link llvm libraries to our shared library (#3973) This fixes link errors seen on my environment. (macOS 15.2, x86-64, Xcode 16.2) Tested as: ``` mkdir b cd b cmake -D WAMR_BUILD_JIT=1 -D LLVM_DIR=/usr/local/opt/llvm@19/lib/cmake/llvm .. make ``` --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bd82fc83a..a637c3643c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ 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 INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT}) + 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 () From 8ac06490db10cea20fdc07784555f93e60130805 Mon Sep 17 00:00:00 2001 From: James Ring Date: Mon, 23 Dec 2024 15:25:52 -0800 Subject: [PATCH 046/431] Set thread information earlier in exec_env creation (#3967) For boundary checking, WAMR calls `pthread_attr_np`, which is unfortunately quite slow on Linux when not called on the main thread (see https://github.com/bytecodealliance/wasm-micro-runtime/issues/3966 for discussion). This change moves the cost of stack bounds checking earlier in the wasm_exec_env creation process. The idea is that it's perhaps better to pay the price when creating the execution environment rather than in the first function call. The original code is left in place inside `call_wasm_with_hw_bound_check` in case the `wasm_exec_env` is created via `wasm_runtime_spawn_exec_env`. --- core/shared/platform/common/posix/posix_thread.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/shared/platform/common/posix/posix_thread.c b/core/shared/platform/common/posix/posix_thread.c index 5ec957e523..1d10246068 100644 --- a/core/shared/platform/common/posix/posix_thread.c +++ b/core/shared/platform/common/posix/posix_thread.c @@ -712,6 +712,13 @@ os_thread_signal_init(os_signal_handler handler) #if WASM_DISABLE_STACK_HW_BOUND_CHECK == 0 sigalt_stack_base_addr = map_addr; #endif + +#if defined(os_thread_local_attribute) + // calculate and cache the new stack boundary. + // see https://github.com/bytecodealliance/wasm-micro-runtime/issues/3966 + (void)os_thread_get_stack_boundary(); +#endif + signal_handler = handler; thread_signal_inited = true; return 0; From 70bec1407056dd2ed8db992713189e2d018a3f36 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 24 Dec 2024 20:19:40 +0800 Subject: [PATCH 047/431] Add Tianlong into code owners (#3970) --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index d8ec4c1b38..990dcfce2c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -22,7 +22,7 @@ # If none of the later patterns match, assign to anyone. This team is the # parent of all the other teams and automatically includes everyone on those # teams. -* @loganek @lum1n0us @no1wudi @wenyongh @xujuntwt95329 @yamt +* @loganek @lum1n0us @no1wudi @TianlongLiang @wenyongh @xujuntwt95329 @yamt # Some parts of the project require more specialized knowledge. In those areas # we designate smaller groups who are more likely to be aware of who's working From bf2f36619bc82b37279001d8b66a1eefc3dff704 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 13:31:17 +0800 Subject: [PATCH 048/431] build(deps): Bump github/codeql-action from 3.27.9 to 3.28.0 (#3982) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.9 to 3.28.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.27.9...v3.28.0) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-minor ... 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 697aba4b0a..0df082baba 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.27.9 + uses: github/codeql-action/init@v3.28.0 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.27.9 + uses: github/codeql-action/analyze@v3.28.0 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.27.9 + uses: github/codeql-action/upload-sarif@v3.28.0 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 3fa3182929..5ac94278d7 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@dd7559424621a6dd0b32ababe9e4b271a87f78d2 # v2.2.4 + uses: github/codeql-action/upload-sarif@78760076e3f08852c2c3aeb5334f70d074e28c59 # v2.2.4 with: sarif_file: results.sarif From 04f1071f1c08b47d734acf0e74511bfeef7c5568 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 13:31:37 +0800 Subject: [PATCH 049/431] build(deps): Bump actions/upload-artifact from 4.4.3 to 4.5.0 (#3981) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.3 to 4.5.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.4.3...v4.5.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... 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 0df082baba..1da37a4c30 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.4.3 + uses: actions/upload-artifact@v4.5.0 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 31427d43fc..b6ca914fba 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -350,7 +350,7 @@ jobs: - name: upload the log if: always() - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 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 5ac94278d7..425eda532e 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@184d73b71b93c222403b2e7f1ffebe4508014249 # v3.1.0 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v3.1.0 with: name: SARIF file path: results.sarif From 9b807660d55fe3ff901714a52ffc804508618bfa Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 25 Dec 2024 21:46:48 +0800 Subject: [PATCH 050/431] Break aot_create_comp_data into small functions Signed-off-by: Huang Qi --- core/iwasm/compilation/aot.c | 299 ++++++++++++++++++++++++++--------- 1 file changed, 220 insertions(+), 79 deletions(-) diff --git a/core/iwasm/compilation/aot.c b/core/iwasm/compilation/aot.c index 0a2cae1f0f..c35a9782cc 100644 --- a/core/iwasm/compilation/aot.c +++ b/core/iwasm/compilation/aot.c @@ -487,60 +487,70 @@ calculate_struct_field_sizes_offsets(AOTCompData *comp_data, bool is_target_x86, } #endif -AOTCompData * -aot_create_comp_data(WASMModule *module, const char *target_arch, - bool gc_enabled) +/** + * Checks if target architecture is 64-bit based on target_arch string. + * + * @param target_arch The target architecture string (e.g. "x86_64", "aarch64") + * @return true if target is 64-bit architecture, false otherwise + * + * If target_arch is NULL, detection is based on UINTPTR_MAX. + * Otherwise looks for "64" in target_arch string. + */ +static bool +arch_is_64bit(const char *target_arch) { - AOTCompData *comp_data; - uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0, i, j; - uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0; - uint64 size; - bool is_64bit_target = false; -#if WASM_ENABLE_GC != 0 - bool is_target_x86 = false; -#endif - -#if WASM_ENABLE_GC != 0 if (!target_arch) { -#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \ - || defined(BUILD_TARGET_X86_32) - is_target_x86 = true; +#if UINTPTR_MAX == UINT64_MAX + return true; +#else + return false; #endif } - else { - if (!strncmp(target_arch, "x86_64", 6) - || !strncmp(target_arch, "i386", 4)) - is_target_x86 = true; - } -#endif + /* All 64bit targets contains "64" string in their target name */ + return strstr(target_arch, "64") != NULL; +} +/** + * Checks if target architecture is x86/x64 based on target_arch string. + * + * @param target_arch The target architecture string (e.g. "x86_64", "i386") + * @return true if target is x86/x64 architecture, false otherwise + * + * If target_arch is NULL, detection is based on build-time definitions. + * Otherwise checks for x86_64 or i386 in target_arch string. + */ +static bool +arch_is_x86(const char *target_arch) +{ if (!target_arch) { -#if UINTPTR_MAX == UINT64_MAX - is_64bit_target = true; +#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \ + || defined(BUILD_TARGET_X86_32) + return true; +#else + return false; #endif } - else { - /* All 64bit targets contains "64" string in their target name */ - if (strstr(target_arch, "64") != NULL) { - is_64bit_target = true; - } - } - - /* Allocate memory */ - if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) { - aot_set_last_error("create compile data failed.\n"); - return NULL; - } + return !strncmp(target_arch, "x86_64", 6) + || !strncmp(target_arch, "i386", 4); +} - memset(comp_data, 0, sizeof(AOTCompData)); +/** + * Initialize memory information in AOT compilation data from WASM module. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing memory information + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_memories(AOTCompData *comp_data, WASMModule *module) +{ + uint32 i, j; + uint64 size; comp_data->memory_count = module->import_memory_count + module->memory_count; - /* TODO: create import memories */ - /* Allocate memory for memory array, reserve one AOTMemory space at least */ - /* TODO: multi-memory */ if (!comp_data->memory_count) comp_data->memory_count = 1; @@ -548,7 +558,7 @@ aot_create_comp_data(WASMModule *module, const char *target_arch, if (size >= UINT32_MAX || !(comp_data->memories = wasm_runtime_malloc((uint32)size))) { aot_set_last_error("create memories array failed.\n"); - goto fail; + return false; } memset(comp_data->memories, 0, size); @@ -580,22 +590,30 @@ aot_create_comp_data(WASMModule *module, const char *target_arch, } } - /* Create memory data segments */ - comp_data->mem_init_data_count = module->data_seg_count; - if (comp_data->mem_init_data_count > 0 - && !(comp_data->mem_init_data_list = - aot_create_mem_init_data_list(module))) - goto fail; + return true; +} + +/** + * Initialize table information in AOT compilation data from WASM module. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing table information + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_tables(AOTCompData *comp_data, WASMModule *module) +{ + uint32 i, j; + uint64 size; - /* Create tables */ comp_data->table_count = module->import_table_count + module->table_count; if (comp_data->table_count > 0) { size = sizeof(AOTTable) * (uint64)comp_data->table_count; if (size >= UINT32_MAX || !(comp_data->tables = wasm_runtime_malloc((uint32)size))) { - aot_set_last_error("create memories array failed.\n"); - goto fail; + aot_set_last_error("create tables array failed.\n"); + return false; } memset(comp_data->tables, 0, size); for (i = 0; i < comp_data->table_count; i++) { @@ -641,64 +659,150 @@ aot_create_comp_data(WASMModule *module, const char *target_arch, } } - /* Create table data segments */ + return true; +} + +/** + * Initialize memory segment information in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing memory segments + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_memory_segments(AOTCompData *comp_data, WASMModule *module) +{ + comp_data->mem_init_data_count = module->data_seg_count; + if (comp_data->mem_init_data_count > 0 + && !(comp_data->mem_init_data_list = + aot_create_mem_init_data_list(module))) { + return false; + } + return true; +} + +/** + * Initialize table segment information in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing table segments + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_table_segments(AOTCompData *comp_data, WASMModule *module) +{ comp_data->table_init_data_count = module->table_seg_count; if (comp_data->table_init_data_count > 0 && !(comp_data->table_init_data_list = - aot_create_table_init_data_list(module))) - goto fail; + aot_create_table_init_data_list(module))) { + return false; + } + return true; +} - /* Create import globals */ +/** + * Initialize global variable information in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing global information + * @param gc_enabled whether garbage collection is enabled + * @param import_global_data_size_64bit [out] size of imported global data for + * 64-bit + * @param import_global_data_size_32bit [out] size of imported global data for + * 32-bit + * @param global_data_size_64bit [out] size of global data for 64-bit + * @param global_data_size_32bit [out] size of global data for 32-bit + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_globals(AOTCompData *comp_data, WASMModule *module, bool gc_enabled, + uint32 *import_global_data_size_64bit, + uint32 *import_global_data_size_32bit, + uint32 *global_data_size_64bit, uint32 *global_data_size_32bit) +{ comp_data->import_global_count = module->import_global_count; if (comp_data->import_global_count > 0 && !(comp_data->import_globals = aot_create_import_globals( - module, gc_enabled, &import_global_data_size_64bit, - &import_global_data_size_32bit))) - goto fail; + module, gc_enabled, import_global_data_size_64bit, + import_global_data_size_32bit))) { + return false; + } - /* Create globals */ comp_data->global_count = module->global_count; if (comp_data->global_count && !(comp_data->globals = aot_create_globals( - module, gc_enabled, import_global_data_size_64bit, - import_global_data_size_32bit, &global_data_size_64bit, - &global_data_size_32bit))) - goto fail; + module, gc_enabled, *import_global_data_size_64bit, + *import_global_data_size_32bit, global_data_size_64bit, + global_data_size_32bit))) { + return false; + } comp_data->global_data_size_64bit = - import_global_data_size_64bit + global_data_size_64bit; + *import_global_data_size_64bit + *global_data_size_64bit; comp_data->global_data_size_32bit = - import_global_data_size_32bit + global_data_size_32bit; + *import_global_data_size_32bit + *global_data_size_32bit; + + return true; +} - /* Create types, they are checked by wasm loader */ +/** + * Initialize type information in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing type information + * @param is_target_x86 whether the target architecture is x86 + * @param gc_enabled whether garbage collection is enabled + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_types(AOTCompData *comp_data, WASMModule *module, bool is_target_x86, + bool gc_enabled) +{ comp_data->type_count = module->type_count; comp_data->types = module->types; #if WASM_ENABLE_GC != 0 - /* Calculate the field sizes and field offsets for 64-bit and 32-bit - targets since they may vary in 32-bit target and 64-bit target */ calculate_struct_field_sizes_offsets(comp_data, is_target_x86, gc_enabled); #endif + return true; +} - /* Create import functions */ +/** + * Initialize function information in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing function information + * @param is_64bit_target whether the target architecture is 64-bit + * @return true if initialization succeeded, false otherwise + */ +static bool +aot_init_functions(AOTCompData *comp_data, WASMModule *module, + bool is_64bit_target) +{ comp_data->import_func_count = module->import_function_count; if (comp_data->import_func_count - && !(comp_data->import_funcs = aot_create_import_funcs(module))) - goto fail; + && !(comp_data->import_funcs = aot_create_import_funcs(module))) { + return false; + } - /* Create functions */ comp_data->func_count = module->function_count; if (comp_data->func_count && !(comp_data->funcs = - aot_create_funcs(module, is_64bit_target ? 8 : 4))) - goto fail; + aot_create_funcs(module, is_64bit_target ? 8 : 4))) { + return false; + } -#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 - /* Create custom name section */ - comp_data->name_section_buf = module->name_section_buf; - comp_data->name_section_buf_end = module->name_section_buf_end; -#endif + return true; +} - /* Create aux data/heap/stack information */ +/** + * Initialize auxiliary data in AOT compilation data. + * + * @param comp_data the AOT compilation data structure to initialize + * @param module the source WASM module containing auxiliary data + */ +static void +aot_init_aux_data(AOTCompData *comp_data, WASMModule *module) +{ comp_data->aux_data_end_global_index = module->aux_data_end_global_index; comp_data->aux_data_end = module->aux_data_end; comp_data->aux_heap_base_global_index = module->aux_heap_base_global_index; @@ -717,6 +821,43 @@ aot_create_comp_data(WASMModule *module, const char *target_arch, comp_data->string_literal_ptrs_wp = module->string_literal_ptrs; comp_data->string_literal_lengths_wp = module->string_literal_lengths; #endif +} + +AOTCompData * +aot_create_comp_data(WASMModule *module, const char *target_arch, + bool gc_enabled) +{ + AOTCompData *comp_data; + uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0; + uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0; + bool is_64bit_target = arch_is_64bit(target_arch); + bool is_target_x86 = arch_is_x86(target_arch); + + if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) { + aot_set_last_error("create compile data failed.\n"); + return NULL; + } + memset(comp_data, 0, sizeof(AOTCompData)); + + if (!aot_init_memories(comp_data, module) + || !aot_init_memory_segments(comp_data, module) + || !aot_init_tables(comp_data, module) + || !aot_init_table_segments(comp_data, module) + || !aot_init_globals(comp_data, module, gc_enabled, + &import_global_data_size_64bit, + &import_global_data_size_32bit, + &global_data_size_64bit, &global_data_size_32bit) + || !aot_init_types(comp_data, module, is_target_x86, gc_enabled) + || !aot_init_functions(comp_data, module, is_64bit_target)) { + goto fail; + } + +#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 + comp_data->name_section_buf = module->name_section_buf; + comp_data->name_section_buf_end = module->name_section_buf_end; +#endif + + aot_init_aux_data(comp_data, module); comp_data->wasm_module = module; From 38cf2742924d4e82593d3b27e27d29f1f5f61359 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 26 Dec 2024 15:15:25 +0800 Subject: [PATCH 051/431] Optimize memory initialization handling in AOT loader (#3983) Save memory if the file buffer is always exist before exit. Signed-off-by: Huang Qi --- core/iwasm/aot/aot_loader.c | 75 ++++++++++++++++++++++++++++++++---- core/iwasm/compilation/aot.c | 25 +++++++++--- core/iwasm/compilation/aot.h | 2 +- 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 239e328bd4..bde3ee034d 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -967,13 +967,29 @@ destroy_import_memories(AOTImportMemory *import_memories) wasm_runtime_free(import_memories); } +/** + * Free memory initialization data segments. + * + * @param module the AOT module containing the data + * @param data_list array of memory initialization data segments to free + * @param count number of segments in the data_list array + */ + static void -destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count) +destroy_mem_init_data_list(AOTModule *module, AOTMemInitData **data_list, + uint32 count) { uint32 i; + /* Free each memory initialization data segment */ for (i = 0; i < count; i++) - if (data_list[i]) + if (data_list[i]) { + /* If the module owns the binary data, free the bytes buffer */ + if (module->is_binary_freeable && data_list[i]->bytes) + wasm_runtime_free(data_list[i]->bytes); + /* Free the data segment structure itself */ wasm_runtime_free(data_list[i]); + } + /* Free the array of data segment pointers */ wasm_runtime_free(data_list); } @@ -982,6 +998,22 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, InitializerExpression *expr, char *error_buf, uint32 error_buf_size); +/** + * Load memory initialization data segments from the AOT module. + * + * This function reads memory initialization data segments from the buffer and + * creates AOTMemInitData structures for each segment. The data can either be + * cloned into new memory or referenced directly from the buffer. + * + * @param p_buf pointer to buffer containing memory init data + * @param buf_end end of buffer + * @param module the AOT module being loaded + * @param error_buf buffer for error messages + * @param error_buf_size size of error buffer + * + * @return true if successful, false if error occurred + */ + static bool load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, char *error_buf, @@ -1013,8 +1045,8 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end, return false; } read_uint32(buf, buf_end, byte_count); - size = offsetof(AOTMemInitData, bytes) + (uint64)byte_count; - if (!(data_list[i] = loader_malloc(size, error_buf, error_buf_size))) { + if (!(data_list[i] = loader_malloc(sizeof(AOTMemInitData), error_buf, + error_buf_size))) { return false; } @@ -1026,8 +1058,22 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end, data_list[i]->offset.init_expr_type = init_value.init_expr_type; data_list[i]->offset.u = init_value.u; data_list[i]->byte_count = byte_count; - read_byte_array(buf, buf_end, data_list[i]->bytes, - data_list[i]->byte_count); + data_list[i]->bytes = NULL; + /* If the module owns the binary data, clone the bytes buffer */ + if (module->is_binary_freeable) { + if (byte_count > 0) { + if (!(data_list[i]->bytes = loader_malloc(byte_count, error_buf, + error_buf_size))) { + return false; + } + read_byte_array(buf, buf_end, data_list[i]->bytes, + data_list[i]->byte_count); + } + } + else { + data_list[i]->bytes = (uint8 *)buf; + buf += byte_count; + } } *p_buf = buf; @@ -1036,6 +1082,21 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end, return false; } +/** + * Load memory information from the AOT module. + * + * This function reads memory-related data including import memory count, + * memory count, memory flags, page sizes, and memory initialization data. + * + * @param p_buf pointer to buffer containing memory info + * @param buf_end end of buffer + * @param module the AOT module being loaded + * @param error_buf buffer for error messages + * @param error_buf_size size of error buffer + * + * @return true if successful, false if error occurred + */ + static bool load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, char *error_buf, uint32 error_buf_size) @@ -4356,7 +4417,7 @@ aot_unload(AOTModule *module) wasm_runtime_free(module->memories); if (module->mem_init_data_list) - destroy_mem_init_data_list(module->mem_init_data_list, + destroy_mem_init_data_list(module, module->mem_init_data_list, module->mem_init_data_count); if (module->native_symbol_list) diff --git a/core/iwasm/compilation/aot.c b/core/iwasm/compilation/aot.c index 0a2cae1f0f..699f3c875e 100644 --- a/core/iwasm/compilation/aot.c +++ b/core/iwasm/compilation/aot.c @@ -36,8 +36,11 @@ aot_destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count) { uint32 i; for (i = 0; i < count; i++) - if (data_list[i]) + if (data_list[i]) { + if (data_list[i]->bytes) + wasm_runtime_free(data_list[i]->bytes); wasm_runtime_free(data_list[i]); + } wasm_runtime_free(data_list); } @@ -60,8 +63,7 @@ aot_create_mem_init_data_list(const WASMModule *module) /* Create each memory data segment */ for (i = 0; i < module->data_seg_count; i++) { - size = offsetof(AOTMemInitData, bytes) - + (uint64)module->data_segments[i]->data_length; + size = sizeof(AOTMemInitData); if (size >= UINT32_MAX || !(data_list[i] = wasm_runtime_malloc((uint32)size))) { aot_set_last_error("allocate memory failed."); @@ -69,18 +71,31 @@ aot_create_mem_init_data_list(const WASMModule *module) } #if WASM_ENABLE_BULK_MEMORY != 0 + /* Set bulk memory specific properties if enabled */ data_list[i]->is_passive = module->data_segments[i]->is_passive; data_list[i]->memory_index = module->data_segments[i]->memory_index; #endif data_list[i]->offset = module->data_segments[i]->base_offset; data_list[i]->byte_count = module->data_segments[i]->data_length; - memcpy(data_list[i]->bytes, module->data_segments[i]->data, - module->data_segments[i]->data_length); + data_list[i]->bytes = NULL; + /* Allocate memory for AOT compiler is OK, because the data segment + * is small and the host memory is enough */ + if (data_list[i]->byte_count > 0) { + data_list[i]->bytes = wasm_runtime_malloc(data_list[i]->byte_count); + if (!data_list[i]->bytes) { + aot_set_last_error("allocate memory failed."); + goto fail; + } + /* Copy the actual data bytes from the WASM module */ + memcpy(data_list[i]->bytes, module->data_segments[i]->data, + module->data_segments[i]->data_length); + } } return data_list; fail: + /* Clean up allocated memory in case of failure */ aot_destroy_mem_init_data_list(data_list, module->data_seg_count); return NULL; } diff --git a/core/iwasm/compilation/aot.h b/core/iwasm/compilation/aot.h index 98d2cc6cc7..973d198caa 100644 --- a/core/iwasm/compilation/aot.h +++ b/core/iwasm/compilation/aot.h @@ -103,7 +103,7 @@ typedef struct AOTMemInitData { /* Byte count */ uint32 byte_count; /* Byte array */ - uint8 bytes[1]; + uint8 *bytes; } AOTMemInitData; /** From 7f3e0df21c7c8ff6f999597d14e83eacbd0a378f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Sun, 29 Dec 2024 15:52:12 +0800 Subject: [PATCH 052/431] Handle a new scenario where an item is both exported and imported. (#3984) --- core/iwasm/common/wasm_runtime_common.c | 154 ++++++++++++++++++------ 1 file changed, 118 insertions(+), 36 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 26aab96642..5517fe60fc 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -4266,31 +4266,68 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index, export_type->kind = aot_export->kind; switch (export_type->kind) { case WASM_IMPORT_EXPORT_KIND_FUNC: - export_type->u.func_type = - (AOTFuncType *)aot_module - ->types[aot_module->func_type_indexes - [aot_export->index - - aot_module->import_func_count]]; + { + if (aot_export->index < aot_module->import_func_count) { + export_type->u.func_type = + (AOTFuncType *)aot_module + ->import_funcs[aot_export->index] + .func_type; + } + else { + export_type->u.func_type = + (AOTFuncType *)aot_module + ->types[aot_module->func_type_indexes + [aot_export->index + - aot_module->import_func_count]]; + } break; + } case WASM_IMPORT_EXPORT_KIND_GLOBAL: - export_type->u.global_type = - &aot_module - ->globals[aot_export->index - - aot_module->import_global_count] - .type; + { + if (aot_export->index < aot_module->import_global_count) { + export_type->u.global_type = + &aot_module->import_globals[aot_export->index].type; + } + else { + export_type->u.global_type = + &aot_module + ->globals[aot_export->index + - aot_module->import_global_count] + .type; + } break; + } case WASM_IMPORT_EXPORT_KIND_TABLE: - export_type->u.table_type = - &aot_module - ->tables[aot_export->index - - aot_module->import_table_count] - .table_type; + { + if (aot_export->index < aot_module->import_table_count) { + export_type->u.table_type = + &aot_module->import_tables[aot_export->index] + .table_type; + } + else { + export_type->u.table_type = + &aot_module + ->tables[aot_export->index + - aot_module->import_table_count] + .table_type; + } break; + } case WASM_IMPORT_EXPORT_KIND_MEMORY: - export_type->u.memory_type = - &aot_module->memories[aot_export->index - - aot_module->import_memory_count]; + { + if (aot_export->index < aot_module->import_memory_count) { + export_type->u.memory_type = + &aot_module->import_memories[aot_export->index] + .mem_type; + } + else { + export_type->u.memory_type = + &aot_module + ->memories[aot_export->index + - aot_module->import_memory_count]; + } break; + } default: bh_assert(0); break; @@ -4312,31 +4349,76 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index, export_type->kind = wasm_export->kind; switch (export_type->kind) { case WASM_IMPORT_EXPORT_KIND_FUNC: - export_type->u.func_type = - wasm_module - ->functions[wasm_export->index - - wasm_module->import_function_count] - ->func_type; + { + if (wasm_export->index < wasm_module->import_function_count) { + export_type->u.func_type = + (WASMFuncType *)wasm_module + ->import_functions[wasm_export->index] + .u.function.func_type; + } + else { + export_type->u.func_type = + wasm_module + ->functions[wasm_export->index + - wasm_module->import_function_count] + ->func_type; + } + break; + } case WASM_IMPORT_EXPORT_KIND_GLOBAL: - export_type->u.global_type = - &wasm_module - ->globals[wasm_export->index - - wasm_module->import_global_count] - .type; + { + if (wasm_export->index < wasm_module->import_global_count) { + export_type->u.global_type = + (WASMGlobalType *)&wasm_module + ->import_globals[wasm_export->index] + .u.global.type; + } + else { + export_type->u.global_type = + &wasm_module + ->globals[wasm_export->index + - wasm_module->import_global_count] + .type; + } + break; + } case WASM_IMPORT_EXPORT_KIND_TABLE: - export_type->u.table_type = - &wasm_module - ->tables[wasm_export->index - - wasm_module->import_table_count] - .table_type; + { + if (wasm_export->index < wasm_module->import_table_count) { + export_type->u.table_type = + (WASMTableType *)&wasm_module + ->import_tables[wasm_export->index] + .u.table.table_type; + } + else { + export_type->u.table_type = + &wasm_module + ->tables[wasm_export->index + - wasm_module->import_table_count] + .table_type; + } + break; + } case WASM_IMPORT_EXPORT_KIND_MEMORY: - export_type->u.memory_type = - &wasm_module->memories[wasm_export->index - - wasm_module->import_memory_count]; + { + if (wasm_export->index < wasm_module->import_memory_count) { + export_type->u.memory_type = + (WASMMemoryType *)&wasm_module + ->import_memories[wasm_export->index] + .u.memory.mem_type; + } + else { + export_type->u.memory_type = + &wasm_module + ->memories[wasm_export->index + - wasm_module->import_memory_count]; + } + break; + } default: bh_assert(0); break; From 31ff576edfa01f5f928069deab9cf75a9eef512d Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Fri, 3 Jan 2025 02:44:25 +0000 Subject: [PATCH 053/431] Error message improvement (#4000) Improve error message in the scenario where the runtime was built with ref types disabled but the module uses reference types feature. --- core/iwasm/interpreter/wasm_loader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 79ed996d87..91237c0075 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -4237,7 +4237,10 @@ check_table_index(const WASMModule *module, uint32 table_index, char *error_buf, { #if WASM_ENABLE_REF_TYPES == 0 && WASM_ENABLE_GC == 0 if (table_index != 0) { - set_error_buf(error_buf, error_buf_size, "zero byte expected"); + set_error_buf( + error_buf, error_buf_size, + "zero byte expected. The module uses reference types feature " + "which is disabled in the runtime."); return false; } #endif From 099056b076626c0f9df5664f1484f76e1c4d5ee5 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 3 Jan 2025 14:37:09 +0800 Subject: [PATCH 054/431] Ensure __heap_base and __data_end global indices are validated against import count (#3996) --- core/iwasm/interpreter/wasm_loader.c | 14 ++++++++++++++ core/iwasm/interpreter/wasm_mini_loader.c | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 91237c0075..e01e17fe94 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -5927,6 +5927,13 @@ load_from_sections(WASMModule *module, WASMSection *sections, for (i = 0; i < module->export_count; i++, export ++) { if (export->kind == EXPORT_KIND_GLOBAL) { if (!strcmp(export->name, "__heap_base")) { + if (export->index < module->import_global_count) { + LOG_DEBUG("Skip the process if __heap_base is imported " + "instead of being a local global"); + continue; + } + + /* only process linker-generated symbols */ global_index = export->index - module->import_global_count; global = module->globals + global_index; if (global->type.val_type == VALUE_TYPE_I32 @@ -5941,6 +5948,13 @@ load_from_sections(WASMModule *module, WASMSection *sections, } } else if (!strcmp(export->name, "__data_end")) { + if (export->index < module->import_global_count) { + LOG_DEBUG("Skip the process if __data_end is imported " + "instead of being a local global"); + continue; + } + + /* only process linker-generated symbols */ global_index = export->index - module->import_global_count; global = module->globals + global_index; if (global->type.val_type == VALUE_TYPE_I32 diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 4dad55523b..de9e22018c 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2736,6 +2736,12 @@ load_from_sections(WASMModule *module, WASMSection *sections, for (i = 0; i < module->export_count; i++, export ++) { if (export->kind == EXPORT_KIND_GLOBAL) { if (!strcmp(export->name, "__heap_base")) { + if (export->index < module->import_global_count) { + LOG_DEBUG("Skip the process if __heap_base is imported " + "instead of being a local global"); + continue; + } + global_index = export->index - module->import_global_count; global = module->globals + global_index; if (global->type.val_type == VALUE_TYPE_I32 @@ -2750,6 +2756,12 @@ load_from_sections(WASMModule *module, WASMSection *sections, } } else if (!strcmp(export->name, "__data_end")) { + if (export->index < module->import_global_count) { + LOG_DEBUG("Skip the process if __data_end is imported " + "instead of being a local global"); + continue; + } + global_index = export->index - module->import_global_count; global = module->globals + global_index; if (global->type.val_type == VALUE_TYPE_I32 From 1958808a2485e14a179dd57563dbb628c4268c84 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Sun, 5 Jan 2025 15:27:40 +0800 Subject: [PATCH 055/431] Fix table index calculations in wasm_loader and wasm_mini_loader (#4004) --- core/iwasm/interpreter/wasm_loader.c | 11 +++++++---- core/iwasm/interpreter/wasm_mini_loader.c | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index e01e17fe94..533538adc6 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -58,7 +58,9 @@ is_table_64bit(WASMModule *module, uint32 table_idx) return !!(module->import_tables[table_idx].u.table.table_type.flags & TABLE64_FLAG); else - return !!(module->tables[table_idx].table_type.flags & TABLE64_FLAG); + return !!(module->tables[table_idx - module->import_table_count] + .table_type.flags + & TABLE64_FLAG); return false; } @@ -4285,7 +4287,8 @@ check_table_elem_type(WASMModule *module, uint32 table_index, module->import_tables[table_index].u.table.table_type.elem_type; else table_declared_elem_type = - (module->tables + table_index)->table_type.elem_type; + module->tables[table_index - module->import_table_count] + .table_type.elem_type; if (table_declared_elem_type == type_from_elem_seg) return true; @@ -10854,12 +10857,12 @@ get_table_elem_type(const WASMModule *module, uint32 table_idx, else { if (p_elem_type) *p_elem_type = - module->tables[module->import_table_count + table_idx] + module->tables[table_idx - module->import_table_count] .table_type.elem_type; #if WASM_ENABLE_GC != 0 if (p_ref_type) *((WASMRefType **)p_ref_type) = - module->tables[module->import_table_count + table_idx] + module->tables[table_idx - module->import_table_count] .table_type.elem_ref_type; #endif } diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index de9e22018c..e83a200453 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -48,7 +48,9 @@ is_table_64bit(WASMModule *module, uint32 table_idx) return !!(module->import_tables[table_idx].u.table.table_type.flags & TABLE64_FLAG); else - return !!(module->tables[table_idx].table_type.flags & TABLE64_FLAG); + return !!(module->tables[table_idx - module->import_table_count] + .table_type.flags + & TABLE64_FLAG); return false; } @@ -2566,7 +2568,7 @@ get_table_elem_type(const WASMModule *module, uint32 table_idx, module->import_tables[table_idx].u.table.table_type.elem_type; else *p_elem_type = - module->tables[module->import_table_count + table_idx] + module->tables[table_idx - module->import_table_count] .table_type.elem_type; } return true; From 1807eec9d2d38b88545c2fc7208959113750a342 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:34:17 +0800 Subject: [PATCH 056/431] Add an example of how to embed WAMR in Zephyr user mode (#3998) --- .../platforms/zephyr/simple/CMakeLists.txt | 3 +- .../platforms/zephyr/user-mode/CMakeLists.txt | 15 ++ .../platforms/zephyr/user-mode/README.md | 60 ++++++ .../user-mode/lib-wamr-zephyr/CMakeLists.txt | 63 +++++++ .../user-mode/lib-wamr-zephyr/test_wasm.h | 46 +++++ .../lib-wamr-zephyr/test_wasm_riscv64.h | 41 +++++ .../user-mode/lib-wamr-zephyr/wamr_lib.c | 172 ++++++++++++++++++ .../platforms/zephyr/user-mode/prj.conf | 9 + .../platforms/zephyr/user-mode/src/main.c | 78 ++++++++ 9 files changed, 486 insertions(+), 1 deletion(-) create mode 100644 product-mini/platforms/zephyr/user-mode/CMakeLists.txt create mode 100644 product-mini/platforms/zephyr/user-mode/README.md create mode 100644 product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt create mode 100644 product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm.h create mode 100644 product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm_riscv64.h create mode 100644 product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/wamr_lib.c create mode 100644 product-mini/platforms/zephyr/user-mode/prj.conf create mode 100644 product-mini/platforms/zephyr/user-mode/src/main.c diff --git a/product-mini/platforms/zephyr/simple/CMakeLists.txt b/product-mini/platforms/zephyr/simple/CMakeLists.txt index 8b2af15eb7..78dd322858 100644 --- a/product-mini/platforms/zephyr/simple/CMakeLists.txt +++ b/product-mini/platforms/zephyr/simple/CMakeLists.txt @@ -32,7 +32,8 @@ if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) endif () if (NOT DEFINED WAMR_BUILD_LIBC_WASI) - # Disable libc wasi support by default + # Disable libc wasi support by default, in the future, + # it can be enabled if libc wasi file/socket/lock support is ready on Zephyr platform set (WAMR_BUILD_LIBC_WASI 0) endif () diff --git a/product-mini/platforms/zephyr/user-mode/CMakeLists.txt b/product-mini/platforms/zephyr/user-mode/CMakeLists.txt new file mode 100644 index 0000000000..16c9b26dc0 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.13.1) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(wamr_user_mode LANGUAGES C) + +# Add the wamr-lib directory +add_subdirectory(lib-wamr-zephyr) + +# Link the wamr library to the app target +target_link_libraries(app PRIVATE wamr_lib) + +target_sources(app PRIVATE src/main.c) diff --git a/product-mini/platforms/zephyr/user-mode/README.md b/product-mini/platforms/zephyr/user-mode/README.md new file mode 100644 index 0000000000..b157467329 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/README.md @@ -0,0 +1,60 @@ +# How to use WAMR with Zephyr in user mode + +This example demonstrates how to build and run a WebAssembly application in user mode on Zephyr. + +> Note: The user mode is not supported on all Zephyr boards. Please refer to the Zephyr documentation for more information. + +## Setup + +Please refer to the [previous WAMR Zephyr README.md](../simple/README.md) for general Zephyr setup instructions. + +And refer to [official documentation of Zephyr user mode](https://docs.zephyrproject.org/latest/kernel/usermode/index.html) for more information about Zephyr user mode. + +### Enable user mode + +To enable Zephyr user mode, set the `CONFIG_USERSPACE` option to yes in the Zephyr configuration. + +```conf +CONFIG_USERSPACE=y +``` + +And link the WAMR runtime as a separate library in CMakelists.txt. + +```cmake +...WAMR CMake set up... + +zephyr_library_named (wamr_lib) + +zephyr_library_sources ( + ${WAMR_RUNTIME_LIB_SOURCE} + wamr_lib.c +) + +zephyr_library_app_memory (wamr_partition) +``` + +The `wamr_partition` is a memory partition that will be granted to the WAMR runtime. It is defined in the Zephyr application code. + +```C +K_APPMEM_PARTITION_DEFINE(wamr_partition); +``` + +When creating a Zephyr thread, set the thread option to `K_USER` and the timeout to `K_FOREVER`. This can ensure that the `wamr_partition` is granted access to the thread before starting it with `k_thread_start`. + +### Advantage of using WAMR runtime in Zephyr user mode thread + +In a user-mode Zephyr thread, the application can only access a restricted partition of memory it granted to. It creates a sandbox for the WAMR runtime to run in, and the WAMR runtime can only access that memory space, meaning that all global variables in the WAMR runtime and both runtime and wasm app heap memory will be allocated from it. In this way, an extra layer of security is added to the wasm application on top of the wasm sandbox provided by WAMR. + +### Example Targets + +x86_64 QEMU (x86_64) is a 64-bit x86 target for emulating the x86_64 platform. + +```shell +west build -b qemu_x86_tiny . -p always -- -DWAMR_BUILD_TARGET=X86_32 +``` + +Use qemu to run the image. + +```shell +qemu-system-i386 -m 32 -cpu qemu32,+nx,+pae -machine pc -device isa-debug-exit,iobase=0xf4,iosize=0x04 -no-reboot -nographic -net none -pidfile qemu.pid -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -icount shift=5,align=off,sleep=off -rtc clock=vm -kernel ./build/zephyr/zephyr.elf +``` 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 new file mode 100644 index 0000000000..7c68a71ac7 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.8.2) + +set (WAMR_BUILD_PLATFORM "zephyr") + +# Build as X86_32 by default, change to "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", "MIPS" or "XTENSA" +# if we want to support arm, thumb, mips or xtensa +if (NOT DEFINED WAMR_BUILD_TARGET) + set (WAMR_BUILD_TARGET "X86_32") +endif () + +if (NOT DEFINED WAMR_BUILD_INTERP) + # Enable Interpreter by default + set (WAMR_BUILD_INTERP 1) +endif () + +if (NOT DEFINED WAMR_BUILD_AOT) + # Enable AOT by default. + set (WAMR_BUILD_AOT 1) +endif () + +if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) + # Enable libc builtin support by default + set (WAMR_BUILD_LIBC_BUILTIN 1) +endif () + +if (NOT DEFINED WAMR_BUILD_LIBC_WASI) + # Disable libc wasi support by default, in the future, + # it can be enabled if libc wasi file/socket/lock support is ready on Zephyr platform + set (WAMR_BUILD_LIBC_WASI 0) +endif () + +if (WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64" OR WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32") + set (WAMR_BUILD_FAST_INTERP 1) +endif () + +# Limited to global heap usage in Zephyr user mode +set (WAMR_BUILD_GLOBAL_HEAP_POOL 1) + +# Override the global heap size for small devices +if (NOT DEFINED WAMR_BUILD_GLOBAL_HEAP_SIZE) + set (WAMR_BUILD_GLOBAL_HEAP_SIZE 40960) # 40 KB +endif () + +set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..) + +include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) + +# Embed WAMR as a Zephyr library +zephyr_library_named (wamr_lib) + +# Add source files to the library +zephyr_library_sources ( + ${WAMR_RUNTIME_LIB_SOURCE} + wamr_lib.c +) + +# Specify the memory partition where all globals(including the WAMR global heap buffer) +# in the library should be placed. This partition will be defined in the app source code +# and added to the use-mode thread that uses the WAMR library. +zephyr_library_app_memory (wamr_partition) diff --git a/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm.h b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm.h new file mode 100644 index 0000000000..a729cadef3 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/** + * The byte array buffer is the file content of a test wasm binary file, + * which is compiled by wasi-sdk toolchain from C source file of: + * product-mini/app-samples/hello-world/main.c. + */ +unsigned char __aligned(4) wasm_test_file[] = { + 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60, + 0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01, + 0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75, + 0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C, + 0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72, + 0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66, + 0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01, + 0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x13, 0x03, + 0x7F, 0x01, 0x41, 0xC0, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0xBA, 0x08, 0x0B, + 0x7F, 0x00, 0x41, 0xC0, 0x28, 0x0B, 0x07, 0x2C, 0x04, 0x06, 0x6D, 0x65, + 0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74, + 0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, 0x01, 0x0B, 0x5F, 0x5F, 0x68, 0x65, + 0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x02, 0x04, 0x6D, 0x61, + 0x69, 0x6E, 0x00, 0x04, 0x0A, 0xB2, 0x01, 0x01, 0xAF, 0x01, 0x01, 0x03, + 0x7F, 0x23, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02, + 0x24, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x9B, 0x88, 0x80, 0x80, 0x00, + 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41, + 0x80, 0x08, 0x10, 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00, + 0x41, 0xA8, 0x88, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, + 0x1A, 0x41, 0x7F, 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03, + 0x36, 0x02, 0x10, 0x41, 0x80, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41, + 0x10, 0x6A, 0x10, 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21, + 0x04, 0x20, 0x03, 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x88, + 0x80, 0x80, 0x00, 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00, + 0x8D, 0x88, 0x80, 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03, + 0x36, 0x02, 0x00, 0x41, 0x93, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10, + 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80, + 0x80, 0x00, 0x0B, 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80, + 0x80, 0x00, 0x20, 0x04, 0x0B, 0x0B, 0x41, 0x01, 0x00, 0x41, 0x80, 0x08, + 0x0B, 0x3A, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25, + 0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66, + 0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, + 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, + 0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00 +}; diff --git a/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm_riscv64.h b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm_riscv64.h new file mode 100644 index 0000000000..1b45211d7a --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/test_wasm_riscv64.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +unsigned char __aligned(4) wasm_test_file[] = { + 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60, + 0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01, + 0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75, + 0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C, + 0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72, + 0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66, + 0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01, + 0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x12, 0x03, + 0x7F, 0x01, 0x41, 0xC0, 0x01, 0x0B, 0x7F, 0x00, 0x41, 0x3A, 0x0B, 0x7F, + 0x00, 0x41, 0xC0, 0x01, 0x0B, 0x07, 0x2C, 0x04, 0x06, 0x6D, 0x65, 0x6D, + 0x6F, 0x72, 0x79, 0x02, 0x00, 0x04, 0x6D, 0x61, 0x69, 0x6E, 0x00, 0x04, + 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74, 0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, + 0x01, 0x0B, 0x5F, 0x5F, 0x68, 0x65, 0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, + 0x65, 0x03, 0x02, 0x0A, 0xB1, 0x01, 0x01, 0xAE, 0x01, 0x01, 0x03, 0x7F, + 0x23, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02, 0x24, + 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x9B, 0x80, 0x80, 0x80, 0x00, 0x10, + 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41, 0x10, + 0x10, 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00, 0x41, 0xA8, + 0x80, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, + 0x7F, 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03, 0x36, 0x02, + 0x10, 0x41, 0x80, 0x80, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41, 0x10, 0x6A, + 0x10, 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21, 0x04, 0x20, + 0x03, 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x80, 0x80, 0x80, + 0x00, 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00, 0x8D, 0x80, + 0x80, 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03, 0x36, 0x02, + 0x00, 0x41, 0x93, 0x80, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10, 0x82, 0x80, + 0x80, 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80, 0x80, 0x00, + 0x0B, 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80, 0x80, 0x00, + 0x20, 0x04, 0x0B, 0x0B, 0x40, 0x01, 0x00, 0x41, 0x00, 0x0B, 0x3A, 0x62, + 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25, 0x70, 0x0A, 0x00, + 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66, 0x3A, 0x20, 0x25, + 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, + 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x20, 0x62, 0x75, + 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00 +}; diff --git a/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/wamr_lib.c b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/wamr_lib.c new file mode 100644 index 0000000000..a2c639e802 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/wamr_lib.c @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include +#include +#include "bh_platform.h" +#include "bh_assert.h" +#include "bh_log.h" +#include "bh_queue.h" +#include "wasm_export.h" +#if defined(BUILD_TARGET_RISCV64_LP64) || defined(BUILD_TARGET_RISCV32_ILP32) +#include "test_wasm_riscv64.h" +#else +#include "test_wasm.h" +#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */ + +#if defined(BUILD_TARGET_RISCV64_LP64) || defined(BUILD_TARGET_RISCV32_ILP32) +#define CONFIG_GLOBAL_HEAP_BUF_SIZE 5120 +#define CONFIG_APP_STACK_SIZE 512 +#define CONFIG_APP_HEAP_SIZE 512 +#else /* else of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */ +#define CONFIG_GLOBAL_HEAP_BUF_SIZE WASM_GLOBAL_HEAP_SIZE +#define CONFIG_APP_STACK_SIZE 8192 +#define CONFIG_APP_HEAP_SIZE 8192 +#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */ + +static int app_argc; +static char **app_argv; + +/** + * Find the unique main function from a WASM module instance + * and execute that function. + * + * @param module_inst the WASM module instance + * @param argc the number of arguments + * @param argv the arguments array + * + * @return true if the main function is called, false otherwise. + */ +bool +wasm_application_execute_main(wasm_module_inst_t module_inst, int argc, + char *argv[]); + +static void * +app_instance_main(wasm_module_inst_t module_inst) +{ + const char *exception; + wasm_function_inst_t func; + wasm_exec_env_t exec_env; + unsigned argv[2] = { 0 }; + + if (wasm_runtime_lookup_function(module_inst, "main") + || wasm_runtime_lookup_function(module_inst, "__main_argc_argv")) { + LOG_VERBOSE("Calling main function\n"); + wasm_application_execute_main(module_inst, app_argc, app_argv); + } + else if ((func = wasm_runtime_lookup_function(module_inst, "app_main"))) { + exec_env = + wasm_runtime_create_exec_env(module_inst, CONFIG_APP_HEAP_SIZE); + if (!exec_env) { + os_printf("Create exec env failed\n"); + return NULL; + } + + LOG_VERBOSE("Calling app_main function\n"); + wasm_runtime_call_wasm(exec_env, func, 0, argv); + + if (!wasm_runtime_get_exception(module_inst)) { + os_printf("result: 0x%x\n", argv[0]); + } + + wasm_runtime_destroy_exec_env(exec_env); + } + else { + os_printf("Failed to lookup function main or app_main to call\n"); + return NULL; + } + + if ((exception = wasm_runtime_get_exception(module_inst))) + os_printf("%s\n", exception); + + return NULL; +} + +#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0 +static char global_heap_buf[CONFIG_GLOBAL_HEAP_BUF_SIZE] = { 0 }; +#endif + +void +iwasm_main(void *arg1, void *arg2, void *arg3) +{ + int start, end; + start = k_uptime_get_32(); + uint8 *wasm_file_buf = NULL; + uint32 wasm_file_size; + wasm_module_t wasm_module = NULL; + wasm_module_inst_t wasm_module_inst = NULL; + RuntimeInitArgs init_args; + char error_buf[128]; +#if WASM_ENABLE_LOG != 0 + int log_verbose_level = 2; +#endif + + (void)arg1; + (void)arg2; + (void)arg3; + + os_printf("User mode thread: start\n"); + + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + +#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0 + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); +#elif (defined(CONFIG_COMMON_LIBC_MALLOC) \ + && CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) \ + || defined(CONFIG_NEWLIB_LIBC) + init_args.mem_alloc_type = Alloc_With_System_Allocator; +#else +#error "memory allocation scheme is not defined." +#endif + + /* initialize runtime environment */ + if (!wasm_runtime_full_init(&init_args)) { + printf("Init runtime environment failed.\n"); + return; + } + +#if WASM_ENABLE_LOG != 0 + bh_log_set_verbose_level(log_verbose_level); +#endif + + /* load WASM byte buffer from byte buffer of include file */ + wasm_file_buf = (uint8 *)wasm_test_file; + wasm_file_size = sizeof(wasm_test_file); + + /* load WASM module */ + if (!(wasm_module = wasm_runtime_load(wasm_file_buf, wasm_file_size, + error_buf, sizeof(error_buf)))) { + printf("%s\n", error_buf); + goto fail1; + } + + /* instantiate the module */ + if (!(wasm_module_inst = wasm_runtime_instantiate( + wasm_module, CONFIG_APP_STACK_SIZE, CONFIG_APP_HEAP_SIZE, + error_buf, sizeof(error_buf)))) { + printf("%s\n", error_buf); + goto fail2; + } + + /* invoke the main function */ + app_instance_main(wasm_module_inst); + + /* destroy the module instance */ + wasm_runtime_deinstantiate(wasm_module_inst); + +fail2: + /* unload the module */ + wasm_runtime_unload(wasm_module); + +fail1: + /* destroy runtime environment */ + wasm_runtime_destroy(); + + end = k_uptime_get_32(); + + os_printf("User mode thread: elapsed %d\n", (end - start)); +} diff --git a/product-mini/platforms/zephyr/user-mode/prj.conf b/product-mini/platforms/zephyr/user-mode/prj.conf new file mode 100644 index 0000000000..023a3caa20 --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/prj.conf @@ -0,0 +1,9 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +CONFIG_USERSPACE=y +CONFIG_STACK_SENTINEL=y +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_LOG_BUFFER_SIZE=8096 +CONFIG_THREAD_RUNTIME_STATS=y diff --git a/product-mini/platforms/zephyr/user-mode/src/main.c b/product-mini/platforms/zephyr/user-mode/src/main.c new file mode 100644 index 0000000000..4f51e10d3f --- /dev/null +++ b/product-mini/platforms/zephyr/user-mode/src/main.c @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +#include +#include + +#define MAIN_THREAD_STACK_SIZE 2048 +#define MAIN_THREAD_PRIORITY 5 + +static struct k_thread iwasm_user_mode_thread; +K_THREAD_STACK_DEFINE(iwasm_user_mode_thread_stack, MAIN_THREAD_STACK_SIZE); + +extern struct k_mem_partition z_libc_partition; +K_APPMEM_PARTITION_DEFINE(wamr_partition); + +/* WAMR memory domain */ +struct k_mem_domain wamr_domain; + +extern void +iwasm_main(void *arg1, void *arg2, void *arg3); + +bool +iwasm_user_mode(void) +{ + struct k_mem_partition *wamr_domain_parts[] = { &wamr_partition, + &z_libc_partition }; + + printk("wamr_partition start addr: %ld, size: %zu\n", wamr_partition.start, + wamr_partition.size); + + /* Initialize the memory domain with single WAMR partition */ + if (k_mem_domain_init(&wamr_domain, 2, wamr_domain_parts) != 0) { + printk("Failed to initialize memory domain.\n"); + return false; + } + + k_tid_t tid = + k_thread_create(&iwasm_user_mode_thread, iwasm_user_mode_thread_stack, + MAIN_THREAD_STACK_SIZE, iwasm_main, NULL, NULL, NULL, + MAIN_THREAD_PRIORITY, K_USER, K_FOREVER); + + /* Grant WAMR memory domain access to user mode thread */ + if (k_mem_domain_add_thread(&wamr_domain, tid) != 0) { + printk("Failed to add memory domain to thread.\n"); + return false; + } + +#if KERNEL_VERSION_NUMBER < 0x040000 /* version 4.0.0 */ + /* k_thread_start is a legacy API for compatibility. Modern Zephyr threads + * are initialized in the "sleeping" state and do not need special handling + * for "start".*/ + k_thread_start(tid); +#else + /* wakes up thread from sleeping */ + k_wakeup(tid); +#endif + + return tid ? true : false; +} + +#if KERNEL_VERSION_NUMBER < 0x030400 /* version 3.4.0 */ +void +main(void) +{ + iwasm_user_mode(); +} +#else +int +main(void) +{ + iwasm_user_mode(); + return 0; +} +#endif From 9989b1cc1bdfec48bfc114174ef62d997590661a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 6 Jan 2025 11:36:11 +0800 Subject: [PATCH 057/431] [fuzzing] Use software bound-check during fuzzing (#4003) * Update CMakeLists.txt of fuzzing - enable software bound-check - enable wasi - disable libc builtin and multiple modules * Fix off-by-one error in result offset calculation for function calls --- core/iwasm/interpreter/wasm_interp_fast.c | 7 ++++--- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 531468282f..f44644e456 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1670,7 +1670,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, { uint32 ret_idx; WASMFuncType *func_type; - uint32 off, ret_offset; + int32 off; + uint32 ret_offset; uint8 *ret_types; if (cur_func->is_import_func) func_type = cur_func->u.func_import->func_type; @@ -1682,9 +1683,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, ret_offset = prev_frame->ret_offset; for (ret_idx = 0, - off = sizeof(int16) * (func_type->result_count - 1); + off = (int32)sizeof(int16) * (func_type->result_count - 1); ret_idx < func_type->result_count; - ret_idx++, off -= sizeof(int16)) { + ret_idx++, off -= (int32)sizeof(int16)) { if (ret_types[ret_idx] == VALUE_TYPE_I64 || ret_types[ret_idx] == VALUE_TYPE_F64) { PUT_I64_TO_ADDR(prev_frame->lp + ret_offset, diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index 356869d178..6177d27e72 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -66,7 +66,7 @@ if (NOT DEFINED WAMR_BUILD_JIT) endif () if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) - # Enable libc builtin support by default + # Disable libc builtin support by default set (WAMR_BUILD_LIBC_BUILTIN 0) endif () @@ -81,7 +81,7 @@ if (NOT DEFINED WAMR_BUILD_FAST_INTERP) endif () if (NOT DEFINED WAMR_BUILD_MULTI_MODULE) - # Enable multiple modules + # Disable multiple modules set (WAMR_BUILD_MULTI_MODULE 0) endif () @@ -116,6 +116,10 @@ if (WAMR_BUILD_DEBUG_INTERP EQUAL 1) set (WAMR_BUILD_SIMD 0) endif () +# sanitizer may use kHandleSignalExclusive to handle SIGSEGV +# like `UBSAN_OPTIONS=handle_segv=2:...` +set (WAMR_DISABLE_HW_BOUND_CHECK 1) + set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) message([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR}) From a653746b7bea358251805b98e3ea824152659608 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:55:43 +0800 Subject: [PATCH 058/431] Check whether related table has funcref elem in opcode call_indirect (#3999) * check whether table has funcref elem in call_indirect * check whether table has funcref elem in call_indirect when gc is enabled --- core/iwasm/interpreter/wasm_loader.c | 41 +++++++++++++++++++++++ core/iwasm/interpreter/wasm_mini_loader.c | 9 +++++ 2 files changed, 50 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 533538adc6..8065173a43 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -12103,6 +12103,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { int32 idx; WASMFuncType *func_type; + uint32 tbl_elem_type; +#if WASM_ENABLE_GC != 0 + WASMRefType *elem_ref_type = NULL; +#endif read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 @@ -12125,6 +12129,43 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, error_buf_size)) { goto fail; } + tbl_elem_type = + table_idx < module->import_table_count + ? module->import_tables[table_idx] + .u.table.table_type.elem_type + : module->tables[table_idx - module->import_table_count] + .table_type.elem_type; + +#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 + if (tbl_elem_type != VALUE_TYPE_FUNCREF) { + set_error_buf_v(error_buf, error_buf_size, + "type mismatch: instruction requires table " + "of functions but table %u has externref", + table_idx); + goto fail; + } +#elif WASM_ENABLE_GC != 0 + /* Table element must match type ref null func */ + elem_ref_type = + table_idx < module->import_table_count + ? module->import_tables[table_idx] + .u.table.table_type.elem_ref_type + : module->tables[table_idx - module->import_table_count] + .table_type.elem_ref_type; + + if (!wasm_reftype_is_subtype_of( + tbl_elem_type, elem_ref_type, REF_TYPE_FUNCREF, NULL, + module->types, module->type_count)) { + set_error_buf_v(error_buf, error_buf_size, + "type mismatch: instruction requires " + "reference type t match type ref null func" + "in table %u", + table_idx); + goto fail; + } +#else + (void)tbl_elem_type; +#endif #if WASM_ENABLE_FAST_INTERP != 0 /* we need to emit before arguments */ diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index e83a200453..f994f0defa 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -6700,6 +6700,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, goto fail; } + bh_assert( + (table_idx < module->import_table_count + ? module->import_tables[table_idx] + .u.table.table_type.elem_type + : module + ->tables[table_idx - module->import_table_count] + .table_type.elem_type) + == VALUE_TYPE_FUNCREF); + #if WASM_ENABLE_FAST_INTERP != 0 /* we need to emit before arguments */ emit_uint32(loader_ctx, type_idx); From 02683d2eed275e4207bcd7fd964bc62c93806a15 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 9 Jan 2025 13:11:25 +0800 Subject: [PATCH 059/431] Improve stack consistency by ensuring sufficient space for dummy offsets (#4011) One more corner case: if the `frame_offset` increases and becomes equal to the `frame_offset_boundary` after the last assignment within the for loop. --- core/iwasm/interpreter/wasm_loader.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 8065173a43..bb34e29f01 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -11228,21 +11228,23 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 cell_num = wasm_value_type_cell_num(func_type->types[i]); if (i >= available_params) { + /* make sure enough space */ + if (loader_ctx->p_code_compiled == NULL) { + loader_ctx->frame_offset += cell_num; + if (!check_offset_push(loader_ctx, error_buf, + error_buf_size)) + goto fail; + /* for following dummy value assignemnt */ + loader_ctx->frame_offset -= cell_num; + } + /* If there isn't enough data on stack, push a dummy * offset to keep the stack consistent with * frame_ref. * Since the stack is already in polymorphic state, * the opcode will not be executed, so the dummy * offset won't cause any error */ - uint32 n; - - for (n = 0; n < cell_num; n++) { - if (loader_ctx->p_code_compiled == NULL) { - if (!check_offset_push(loader_ctx, - error_buf, - error_buf_size)) - goto fail; - } + for (uint32 n = 0; n < cell_num; n++) { *loader_ctx->frame_offset++ = 0; } } From 902f7d26310b2b2832dddb3a3ca64141fcfc86f7 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 9 Jan 2025 13:13:30 +0800 Subject: [PATCH 060/431] Add documentation regarding security issues and the status of Wasm proposals (#3972) Add documentation regarding security issues and the status of Wasm proposals. --- doc/security_need_to_know.md | 33 +++++++++++++ doc/stability_wasm_proposals.md | 82 +++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 doc/security_need_to_know.md create mode 100644 doc/stability_wasm_proposals.md diff --git a/doc/security_need_to_know.md b/doc/security_need_to_know.md new file mode 100644 index 0000000000..b2b358983d --- /dev/null +++ b/doc/security_need_to_know.md @@ -0,0 +1,33 @@ +# About security issues + +This document aims to explain the process of identifying a security issue and the steps for managing a security issue. + +## identifying a security issue + +It is commonly stated that a security issue is an issue that: + +- Exposes sensitive information to unauthorized parties. +- Allows unauthorized modification of data or system state. +- Affects the availability of the system or its services. +- Permits unauthorized access to the system. +- Enables users to perform actions they should not be able to. +- Allows users to deny actions they have performed. + +Given that WASI is a set of Capability-based APIs, all unauthorized actions are not supposed to happen. Most of the above security concerns can be alleviated. What remains for us is to ensure that the execution of Wasm modules is secure. In other words, do not compromise the sandbox. Unless it is explicitly disabled beforehand. + +Thus, we share most of the criteria for judging security issues with [the Bytecode Alliance](https://github.com/bytecodealliance/rfcs/blob/main/accepted/what-is-considered-a-security-bug.md#definition). + +> [!NOTE] +> keep updating this document as the project evolves. + +## reporting a security issue + +Follow the [same guidelines](https://bytecodealliance.org/security) as other projects within the Bytecode Alliance. + +## managing a security issue + +Before reporting an issue, particularly one related to crashing, consult [the cheat sheet](https://github.com/bytecodealliance/rfcs/blob/main/accepted/what-is-considered-a-security-bug.md#cheat-sheet-is-this-bug-considered-a-security-vulnerability), _Report a security vulnerability_ if it qualifies. + +Upon receiving an issue, thoroughly review [the cheat sheet](https://github.com/bytecodealliance/rfcs/blob/main/accepted/what-is-considered-a-security-bug.md#cheat-sheet-is-this-bug-considered-a-security-vulnerability) to assess and _Report a security vulnerability_ if the issue is indeed a security vulnerability. + +Once a security issue is confirmed, please refer to [the runbook](https://github.com/bytecodealliance/rfcs/blob/main/accepted/vulnerability-response-runbook.md) for the subsequent steps to take. diff --git a/doc/stability_wasm_proposals.md b/doc/stability_wasm_proposals.md new file mode 100644 index 0000000000..98617d15b1 --- /dev/null +++ b/doc/stability_wasm_proposals.md @@ -0,0 +1,82 @@ +# Wasm Proposals + +This document is intended to describe the current status of WebAssembly proposals and WASI proposals in WAMR. + +Only track proposals that are followed in the [WebAssembly proposals](https://github.com/WebAssembly/proposals) and [WASI proposals](https://github.com/WebAssembly/WASI/blob/main/Proposals.md). + +Normally, the document tracks proposals that are in phase 4. However, if a proposal in an earlier phase receives support, it will be added to the list below. + +The _status_ represents the configuration _product-mini/platforms/linux/CMakeLists.txt_. There may be minor differences between the top-level CMakeLists and platform-specific CMakeLists. + +Users can turn those features on or off by using compilation options. If a relevant compilation option is not available(`N/A`), it indicates that the feature is permanently enabled. + +## On-by-default Wasm Proposals + +| 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 | +| Reference Types | Yes | `WAMR_BUILD_REF_TYPES` | +| Sign-extension operators | Yes | N/A | +| WebAssembly C and C++ API | No | N/A | + +[^1]: llvm-jit and aot only. + +## Off-by-default Wasm Proposals + +| Proposal | >= Phase 4 | Compilation Option | +| ----------------------------- | ---------- | -------------------------- | +| Garbage collection | Yes | `WAMR_BUILD_GC` | +| Legacy Exception handling[^2] | No | `WAMR_BUILD_EXCE_HANDLING` | +| Memory64 | Yes | `WAMR_BUILD_MEMORY64` | +| 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` | +| Typed Function References | Yes | `WAMR_BUILD_GC` | + +[^2]: + interpreter only. [a legacy version](https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/legacy/Exceptions.md). + This proposal is currently also known as the "legacy proposal" and still + supported in the web, but can be deprecated in future and the use of + this proposal is discouraged. + +[^3]: interpreter only +[^4]: `WAMR_BUILD_LIB_PTHREAD` can also be used to enable + +## Unimplemented Wasm Proposals + +| Proposal | >= Phase 4 | +| ------------------------------------------- | ---------- | +| Branch Hinting | Yes | +| Custom Annotation Syntax in the Text Format | Yes | +| Exception handling[^5] | Yes | +| Import/Export of Mutable Globals | Yes | +| JS String Builtins | Yes | +| Relaxed SIMD | Yes | + +[^5]: [up-to-date version](https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md) + +## On-by-default WASI Proposals + +| Proposal | >= Phase 4 | Compilation Option | +| -------- | ---------- | ------------------ | + +## Off-by-default WASI Proposals + +| Proposal | >= Phase 4 | Compilation Option | +| -------------------------- | ---------- | ----------------------------- | +| Machine Learning (wasi-nn) | No | `WAMR_BUILD_WASI_NN` | +| Threads | No | `WAMR_BUILD_LIB_WASI_THREADS` | + +## Unimplemented WASI Proposals + +| Proposal | >= Phase 4 | +| -------- | ---------- | + +## WAMR features + +WAMR offers a variety of customizable features to create a highly efficient runtime. For more details, please refer to [build_wamr](./build_wamr.md). From 53da420c414e6c7b2a871b72c58b1f645b8bc0ee Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 13 Jan 2025 07:09:04 +0800 Subject: [PATCH 061/431] Enable shrunk memory by default and add related configurations (#4008) - Enable shrunk memory by default and add related configurations - Improve error messages for memory access alignment checks - Add documentation for WAMR shrunk memory build option - Update NuttX workflow to disable shrunk memory build option --- .github/workflows/spec_test_on_nuttx.yml | 2 +- build-scripts/config_common.cmake | 12 + core/config.h | 4 + core/iwasm/interpreter/wasm_loader.c | 21 +- core/iwasm/interpreter/wasm_mini_loader.c | 15 +- doc/build_wamr.md | 106 ++++---- doc/memory_tune.md | 1 + .../spec-test-script/ignore_cases.patch | 227 ++++++++---------- .../multi_module_ignore_cases.patch | 53 ---- .../spec-test-script/runtest.py | 3 +- tests/wamr-test-suites/test_wamr.sh | 41 ++-- wamr-compiler/CMakeLists.txt | 6 + 12 files changed, 217 insertions(+), 274 deletions(-) diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index b6ca914fba..7f11695835 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -208,7 +208,7 @@ jobs: if: contains(matrix.wamr_test_option.mode, 'aot') working-directory: apps/interpreters/wamr/wamr/wamr-compiler run: | - cmake -Bbuild . + cmake -B build -DWAMR_BUILD_SHRUNK_MEMORY=0 -S . cmake --build build # the nuttx version we use for xtensa requires esptool.py newer than diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 48c5f7be4b..6a30bfb7b7 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -162,6 +162,11 @@ if (WAMR_BUILD_LINUX_PERF EQUAL 1) endif () endif () +if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY) + # Enable shrunk memory by default + set (WAMR_BUILD_SHRUNK_MEMORY 1) +endif () + ######################################## message ("-- Build Configurations:") @@ -599,3 +604,10 @@ endif() if (NOT WAMR_BUILD_SANITIZER STREQUAL "") message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled") endif () +if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1) + add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1) + message (" Shrunk memory enabled") +else () + add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0) + message (" Shrunk memory disabled") +endif () diff --git a/core/config.h b/core/config.h index f08d828d27..27d26f0937 100644 --- a/core/config.h +++ b/core/config.h @@ -698,4 +698,8 @@ #define WASM_ENABLE_SHARED_HEAP 0 #endif +#ifndef WASM_ENABLE_SHRUNK_MEMORY +#define WASM_ENABLE_SHRUNK_MEMORY 1 +#endif + #endif /* end of _CONFIG_H_ */ diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index bb34e29f01..12f4aff75e 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -6156,9 +6156,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } if (!module->possible_memory_grow) { - WASMMemoryImport *memory_import; - WASMMemory *memory; - +#if WASM_ENABLE_SHRUNK_MEMORY != 0 if (aux_data_end_global && aux_heap_base_global && aux_stack_top_global) { uint64 init_memory_size; @@ -6168,7 +6166,8 @@ load_from_sections(WASMModule *module, WASMSection *sections, * valid range of uint32 */ if (shrunk_memory_size <= UINT32_MAX) { if (module->import_memory_count) { - memory_import = &module->import_memories[0].u.memory; + WASMMemoryImport *memory_import = + &module->import_memories[0].u.memory; init_memory_size = (uint64)memory_import->mem_type.num_bytes_per_page * memory_import->mem_type.init_page_count; @@ -6183,7 +6182,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } if (module->memory_count) { - memory = &module->memories[0]; + WASMMemory *memory = &module->memories[0]; init_memory_size = (uint64)memory->num_bytes_per_page * memory->init_page_count; if (shrunk_memory_size <= init_memory_size) { @@ -6196,10 +6195,12 @@ load_from_sections(WASMModule *module, WASMSection *sections, } } } +#endif /* WASM_ENABLE_SHRUNK_MEMORY != 0 */ #if WASM_ENABLE_MULTI_MODULE == 0 if (module->import_memory_count) { - memory_import = &module->import_memories[0].u.memory; + WASMMemoryImport *memory_import = + &module->import_memories[0].u.memory; /* Only resize the memory to one big page if num_bytes_per_page is * in valid range of uint32 */ if (memory_import->mem_type.init_page_count < DEFAULT_MAX_PAGES) { @@ -6215,7 +6216,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } } if (module->memory_count) { - memory = &module->memories[0]; + WASMMemory *memory = &module->memories[0]; /* Only resize(shrunk) the memory size if num_bytes_per_page is in * valid range of uint32 */ if (memory->init_page_count < DEFAULT_MAX_PAGES) { @@ -10021,7 +10022,8 @@ check_memory_access_align(uint8 opcode, uint32 align, char *error_buf, bh_assert(opcode >= WASM_OP_I32_LOAD && opcode <= WASM_OP_I64_STORE32); if (align > mem_access_aligns[opcode - WASM_OP_I32_LOAD]) { set_error_buf(error_buf, error_buf_size, - "alignment must not be larger than natural"); + "invalid memop flags: alignment must not be larger " + "than natural"); return false; } return true; @@ -10060,7 +10062,8 @@ check_simd_memory_access_align(uint8 opcode, uint32 align, char *error_buf, && align > mem_access_aligns_load_lane[opcode - SIMD_v128_load8_lane])) { set_error_buf(error_buf, error_buf_size, - "alignment must not be larger than natural"); + "invalid memop flags: alignment must not be larger " + "than natural"); return false; } diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index f994f0defa..df4d818a39 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2958,9 +2958,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } if (!module->possible_memory_grow) { - WASMMemoryImport *memory_import; - WASMMemory *memory; - +#if WASM_ENABLE_SHRUNK_MEMORY != 0 if (aux_data_end_global && aux_heap_base_global && aux_stack_top_global) { uint64 init_memory_size; @@ -2970,7 +2968,8 @@ load_from_sections(WASMModule *module, WASMSection *sections, * valid range of uint32 */ if (shrunk_memory_size <= UINT32_MAX) { if (module->import_memory_count) { - memory_import = &module->import_memories[0].u.memory; + WASMMemoryImport *memory_import = + &module->import_memories[0].u.memory; init_memory_size = (uint64)memory_import->mem_type.num_bytes_per_page * memory_import->mem_type.init_page_count; @@ -2985,7 +2984,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } if (module->memory_count) { - memory = &module->memories[0]; + WASMMemory *memory = &module->memories[0]; init_memory_size = (uint64)memory->num_bytes_per_page * memory->init_page_count; if (shrunk_memory_size <= init_memory_size) { @@ -2998,9 +2997,11 @@ load_from_sections(WASMModule *module, WASMSection *sections, } } } +#endif /* WASM_ENABLE_SHRUNK_MEMORY != 0 */ if (module->import_memory_count) { - memory_import = &module->import_memories[0].u.memory; + WASMMemoryImport *memory_import = + &module->import_memories[0].u.memory; if (memory_import->mem_type.init_page_count < DEFAULT_MAX_PAGES) { memory_import->mem_type.num_bytes_per_page *= memory_import->mem_type.init_page_count; @@ -3014,7 +3015,7 @@ load_from_sections(WASMModule *module, WASMSection *sections, } if (module->memory_count) { - memory = &module->memories[0]; + WASMMemory *memory = &module->memories[0]; if (memory->init_page_count < DEFAULT_MAX_PAGES) { memory->num_bytes_per_page *= memory->init_page_count; if (memory->init_page_count > 0) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index abf663177d..cde884457b 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -20,7 +20,7 @@ add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) The script `runtime_lib.cmake` defines a number of variables for configuring the WAMR runtime features. You can set these variables in your CMakeList.txt or pass the configurations from cmake command line. -#### **Configure platform and architecture** +### **Configure platform and architecture** - **WAMR_BUILD_PLATFORM**: set the target platform. It can be set to any platform name (folder name) under folder [core/shared/platform](../core/shared/platform). @@ -34,7 +34,7 @@ The script `runtime_lib.cmake` defines a number of variables for configuring the cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM ``` -#### **Configure interpreters** +### **Configure interpreters** - **WAMR_BUILD_INTERP**=1/0: enable or disable WASM interpreter @@ -42,14 +42,14 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM NOTE: the fast interpreter runs ~2X faster than classic interpreter, but consumes about 2X memory to hold the pre-compiled code. -#### **Configure AOT and JITs** +### **Configure AOT and JITs** - **WAMR_BUILD_AOT**=1/0, enable AOT or not, default to enable if not set - **WAMR_BUILD_JIT**=1/0, enable LLVM JIT or not, default to disable if not set - **WAMR_BUILD_FAST_JIT**=1/0, enable Fast JIT or not, default to disable if not set - **WAMR_BUILD_FAST_JIT**=1 and **WAMR_BUILD_JIT**=1, enable Multi-tier JIT, default to disable if not set -#### **Configure LIBC** +### **Configure LIBC** - **WAMR_BUILD_LIBC_BUILTIN**=1/0, build the built-in libc subset for WASM app, default to enable if not set @@ -59,98 +59,98 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM > Note: for platform which doesn't support **WAMR_BUILD_LIBC_WASI**, e.g. Windows, developer can try using **WAMR_BUILD_LIBC_UVWASI**. -#### **Enable Multi-Module feature** +### **Enable Multi-Module feature** - **WAMR_BUILD_MULTI_MODULE**=1/0, default to disable if not set > Note: See [Multiple Modules as Dependencies](./multi_module.md) for more details. -#### **Enable WASM mini loader** +### **Enable WASM mini loader** - **WAMR_BUILD_MINI_LOADER**=1/0, default to disable if not set > Note: the mini loader doesn't check the integrity of the WASM binary file, developer must ensure that the WASM file is well-formed. -#### **Enable shared memory feature** +### **Enable shared memory feature** - **WAMR_BUILD_SHARED_MEMORY**=1/0, default to disable if not set -#### **Enable bulk memory feature** +### **Enable bulk memory feature** - **WAMR_BUILD_BULK_MEMORY**=1/0, default to disable if not set -#### **Enable memory64 feature** +### **Enable memory64 feature** - **WAMR_BUILD_MEMORY64**=1/0, default to disable if not set > Note: Currently, the memory64 feature is only supported in classic interpreter running mode and AOT mode. -#### **Enable thread manager** +### **Enable thread manager** - **WAMR_BUILD_THREAD_MGR**=1/0, default to disable if not set -#### **Enable lib-pthread** +### **Enable lib-pthread** - **WAMR_BUILD_LIB_PTHREAD**=1/0, default to disable if not set > Note: The dependent feature of lib pthread such as the `shared memory` and `thread manager` will be enabled automatically. > See [WAMR pthread library](./pthread_library.md) for more details. -#### **Enable lib-pthread-semaphore** +### **Enable lib-pthread-semaphore** - **WAMR_BUILD_LIB_PTHREAD_SEMAPHORE**=1/0, default to disable if not set > Note: This feature depends on `lib-pthread`, it will be enabled automatically if this feature is enabled. -#### **Enable lib wasi-threads** +### **Enable lib wasi-threads** - **WAMR_BUILD_LIB_WASI_THREADS**=1/0, default to disable if not set > Note: The dependent feature of lib wasi-threads such as the `shared memory` and `thread manager` will be enabled automatically. > See [wasi-threads](./pthread_impls.md#wasi-threads-new) and [Introduction to WAMR WASI threads](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-wasi-threads) for more details. -#### **Enable lib wasi-nn** +### **Enable lib wasi-nn** - **WAMR_BUILD_WASI_NN**=1/0, default to disable if not set > Note: See [WASI-NN](../core/iwasm/libraries/wasi-nn) for more details. -#### **Enable lib wasi-nn GPU mode** +### **Enable lib wasi-nn GPU mode** - **WAMR_BUILD_WASI_NN_ENABLE_GPU**=1/0, default to disable if not set -#### **Enable lib wasi-nn external delegate mode** +### **Enable lib wasi-nn external delegate mode** - **WAMR_BUILD_WASI_NN_ENABLE_EXTERNAL_DELEGATE**=1/0, default to disable if not set - **WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH**=Path to the external delegate shared library (e.g. `libedgetpu.so.1.0` for Coral USB) -#### **Enable lib wasi-nn with `wasi_ephemeral_nn` module support** +### **Enable lib wasi-nn with `wasi_ephemeral_nn` module support** - **WAMR_BUILD_WASI_EPHEMERAL_NN**=1/0, default to disable if not set -#### **Disable boundary check with hardware trap** +### **Disable boundary check with hardware trap** - **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform > Note: by default only platform [linux/darwin/android/windows/vxworks 64-bit](https://github.com/bytecodealliance/wasm-micro-runtime/blob/5fb5119239220b0803e7045ca49b0a29fe65e70e/core/shared/platform/linux/platform_internal.h#L81) will enable the boundary check with hardware trap feature, for 32-bit platforms it's automatically disabled even when the flag is set to 0, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance. The boundary check includes linear memory access boundary and native stack access boundary, if `WAMR_DISABLE_STACK_HW_BOUND_CHECK` below isn't set. -#### **Disable native stack boundary check with hardware trap** +### **Disable native stack boundary check with hardware trap** - **WAMR_DISABLE_STACK_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform, same as `WAMR_DISABLE_HW_BOUND_CHECK`. > Note: When boundary check with hardware trap is disabled, or `WAMR_DISABLE_HW_BOUND_CHECK` is set to 1, the native stack boundary check with hardware trap will be disabled too, no matter what value is set to `WAMR_DISABLE_STACK_HW_BOUND_CHECK`. And when boundary check with hardware trap is enabled, the status of this feature is set according to the value of `WAMR_DISABLE_STACK_HW_BOUND_CHECK`. -#### **Disable async wakeup of blocking operation** +### **Disable async wakeup of blocking operation** - **WAMR_DISABLE_WAKEUP_BLOCKING_OP**=1/0, default to enable if supported by the platform > Note: The feature helps async termination of blocking threads. If you disable it, the runtime can wait for termination of blocking threads possibly forever. -#### **Enable tail call feature** +### **Enable tail call feature** - **WAMR_BUILD_TAIL_CALL**=1/0, default to disable if not set -#### **Enable 128-bit SIMD feature** +### **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. -#### **Enable Exception Handling** +### **Enable Exception Handling** - **WAMR_BUILD_EXCE_HANDLING**=1/0, default to disable if not set > Note: Currently, the exception handling feature is only supported in classic interpreter running mode. -#### **Enable Garbage Collection** +### **Enable Garbage Collection** - **WAMR_BUILD_GC**=1/0, default to disable if not set -#### **Configure Debug** +### **Configure Debug** - **WAMR_BUILD_CUSTOM_NAME_SECTION**=1/0, load the function name from custom name section, default to disable if not set -#### **Enable AOT stack frame feature** +### **Enable AOT stack frame feature** - **WAMR_BUILD_AOT_STACK_FRAME**=1/0, default to disable if not set > Note: if it is enabled, the AOT or JIT stack frames (like stack frame of classic interpreter but only necessary data is committed) will be created for AOT or JIT mode in function calls. And please add `--enable-dump-call-stack` option to wamrc during compiling AOT module. -#### **Enable dump call stack feature** +### **Enable dump call stack feature** - **WAMR_BUILD_DUMP_CALL_STACK**=1/0, default to disable if not set > Note: if it is enabled, the call stack will be dumped when exception occurs. @@ -158,14 +158,14 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM > - For interpreter mode, the function names are firstly extracted from *custom name section*, if this section doesn't exist or the feature is not enabled, then the name will be extracted from the import/export sections > - For AOT/JIT mode, the function names are extracted from import/export section, please export as many functions as possible (for `wasi-sdk` you can use `-Wl,--export-all`) when compiling wasm module, and add `--enable-dump-call-stack --emit-custom-sections=name` option to wamrc during compiling AOT module. -#### **Enable memory profiling (Experiment)** +### **Enable memory profiling (Experiment)** - **WAMR_BUILD_MEMORY_PROFILING**=1/0, default to disable if not set > Note: if it is enabled, developer can use API `void wasm_runtime_dump_mem_consumption(wasm_exec_env_t exec_env)` to dump the memory consumption info. Currently we only profile the memory consumption of module, module_instance and exec_env, the memory consumed by other components such as `wasi-ctx`, `multi-module` and `thread-manager` are not included. > Also refer to [Memory usage estimation for a module](./memory_usage.md). -#### **Enable performance profiling (Experiment)** +### **Enable performance profiling (Experiment)** - **WAMR_BUILD_PERF_PROFILING**=1/0, default to disable if not set > Note: if it is enabled, developer can use API `void wasm_runtime_dump_perf_profiling(wasm_module_inst_t module_inst)` to dump the performance consumption info. Currently we only profile the performance consumption of each WASM function. @@ -173,24 +173,24 @@ Currently we only profile the memory consumption of module, module_instance and > Also refer to [Tune the performance of running wasm/aot file](./perf_tune.md). -#### **Enable the global heap** +### **Enable the global heap** - **WAMR_BUILD_GLOBAL_HEAP_POOL**=1/0, default to disable if not set for all *iwasm* applications, except for the platforms Alios and Zephyr. > **WAMR_BUILD_GLOBAL_HEAP_POOL** is used in the *iwasm* applications provided in the directory `product-mini`. When writing your own host application using WAMR, if you want to use a global heap and allocate memory from it, you must set the initialization argument `mem_alloc_type` to `Alloc_With_Pool`. > The global heap is defined in the documentation [Memory model and memory usage tunning](memory_tune.md). -#### **Set the global heap size** +### **Set the global heap size** - **WAMR_BUILD_GLOBAL_HEAP_SIZE**=n, default to 10 MB (10485760) if not set for all *iwasm* applications, except for the platforms Alios (256 kB), Riot (256 kB) and Zephyr (128 kB). > **WAMR_BUILD_GLOBAL_HEAP_SIZE** is used in the *iwasm* applications provided in the directory `product-mini`. When writing your own host application using WAMR, if you want to set the amount of memory dedicated to the global heap pool, you must set the initialization argument `mem_alloc_option.pool` with the appropriate values. > The global heap is defined in the documentation [Memory model and memory usage tunning](memory_tune.md). > Note: if `WAMR_BUILD_GLOBAL_HEAP_SIZE` is not set and the flag `WAMR_BUILD_SPEC_TEST` is set, the global heap size is equal to 300 MB (314572800), or 100 MB (104857600) when compiled for Intel SGX (Linux). -#### **Set maximum app thread stack size** +### **Set maximum app thread stack size** - **WAMR_APP_THREAD_STACK_SIZE_MAX**=n, default to 8 MB (8388608) if not set > Note: the AOT boundary check with hardware trap mechanism might consume large stack since the OS may lazily grow the stack mapping as a guard page is hit, we may use this configuration to reduce the total stack usage, e.g. -DWAMR_APP_THREAD_STACK_SIZE_MAX=131072 (128 KB). -#### **Set vprintf callback** +### **Set vprintf callback** - **WAMR_BH_VPRINTF**=, default to disable if not set > Note: if the vprintf_callback function is provided by developer, the os_printf() and os_vprintf() in Linux, Darwin, Windows, VxWorks, Android and esp-idf platforms, besides WASI Libc output will call the callback function instead of libc vprintf() function to redirect the stdout output. For example, developer can define the callback function like below outside runtime lib: > @@ -212,7 +212,7 @@ Currently we only profile the memory consumption of module, module_instance and > > and then use `cmake -DWAMR_BH_VPRINTF=my_vprintf ..` to pass the callback function, or add `BH_VPRINTF=my_vprintf` macro for the compiler, e.g. add line `add_definitions(-DBH_VPRINTF=my_vprintf)` in CMakeLists.txt. See [basic sample](../samples/basic/src/main.c) for a usage example. -#### **WAMR_BH_LOG**=, default to disable if not set +### **WAMR_BH_LOG**=, default to disable if not set > Note: if the log_callback function is provided by the developer, WAMR logs are redirected to such callback. For example: > ```C > void my_log(uint32 log_level, const char *file, int line, const char *fmt, ...) @@ -222,20 +222,20 @@ Currently we only profile the memory consumption of module, module_instance and > ``` > See [basic sample](../samples/basic/src/main.c) for a usage example. -#### **Enable reference types feature** +### **Enable reference types feature** - **WAMR_BUILD_REF_TYPES**=1/0, default to enable if not set -#### **Exclude WAMR application entry functions** +### **Exclude WAMR application entry functions** - **WAMR_DISABLE_APP_ENTRY**=1/0, default to disable if not set > Note: The WAMR application entry (`core/iwasm/common/wasm_application.c`) encapsulate some common process to instantiate, execute the wasm functions and print the results. Some platform related APIs are used in these functions, so you can enable this flag to exclude this file if your platform doesn't support those APIs. > *Don't enable this flag if you are building `product-mini`* -#### **Enable source debugging features** +### **Enable source debugging features** - **WAMR_BUILD_DEBUG_INTERP**=1/0, default to 0 if not set > Note: There are some other setup required by source debugging, please refer to [source_debugging.md](./source_debugging.md) and [WAMR source debugging basic](https://bytecodealliance.github.io/wamr.dev/blog/wamr-source-debugging-basic) for more details. -#### **Enable load wasm custom sections** +### **Enable load wasm custom sections** - **WAMR_BUILD_LOAD_CUSTOM_SECTION**=1/0, default to disable if not set > Note: By default, the custom sections are ignored. If the embedder wants to get custom sections from `wasm_module_t`, then `WAMR_BUILD_LOAD_CUSTOM_SECTION` should be enabled, and then `wasm_runtime_get_custom_section` can be used to get a custom section by name. @@ -244,29 +244,29 @@ Currently we only profile the memory consumption of module, module_instance and > For AoT file, must use `--emit-custom-sections` to specify which sections need to be emitted into AoT file, otherwise all custom sections will be ignored. -#### **Stack guard size** +### **Stack guard size** - **WAMR_BUILD_STACK_GUARD_SIZE**=n, default to N/A if not set. > Note: By default, the stack guard size is 1K (1024) or 24K (if uvwasi enabled). -#### **Disable writing the linear memory base address to x86 GS segment register** +### **Disable writing the linear memory base address to x86 GS segment register** - **WAMR_DISABLE_WRITE_GS_BASE**=1/0, default to enable if not set and supported by platform > Note: by default only platform [linux x86-64](https://github.com/bytecodealliance/wasm-micro-runtime/blob/5fb5119239220b0803e7045ca49b0a29fe65e70e/core/shared/platform/linux/platform_internal.h#L67) will enable this feature, for 32-bit platforms it's automatically disabled even when the flag is set to 0. In linux x86-64, writing the linear memory base address to x86 GS segment register may be used to speedup the linear memory access for LLVM AOT/JIT, when `--enable-segue=[]` option is added for `wamrc` or `iwasm`. > See [Enable segue optimization for wamrc when generating the aot file](./perf_tune.md#3-enable-segue-optimization-for-wamrc-when-generating-the-aot-file) for more details. -#### **User defined linear memory allocator** +### **User defined linear memory allocator** - **WAMR_BUILD_ALLOC_WITH_USAGE**=1/0, default to disable if not set > Notes: by default, the linear memory is allocated by system. when it's set to 1 and Alloc_With_Allocator is selected, it will be allocated by customer. -#### **Enable running PGO(Profile-Guided Optimization) instrumented AOT file** +### **Enable running PGO(Profile-Guided Optimization) instrumented AOT file** - **WAMR_BUILD_STATIC_PGO**=1/0, default to disable if not set > Note: See [Use the AOT static PGO method](./perf_tune.md#5-use-the-aot-static-pgo-method) for more details. -#### **Enable linux perf support** +### **Enable linux perf support** - **WAMR_BUILD_LINUX_PERF**=1/0, enable linux perf support to generate the flamegraph to analyze the performance of a wasm application, default to disable if not set > Note: See [Use linux-perf](./perf_tune.md#7-use-linux-perf) for more details. -#### **Enable module instance context APIs** +### **Enable module instance context APIs** - **WAMR_BUILD_MODULE_INST_CONTEXT**=1/0, enable module instance context APIs which can set one or more contexts created by the embedder for a wasm module instance, default to enable if not set: ```C wasm_runtime_create_context_key @@ -277,19 +277,19 @@ Currently we only profile the memory consumption of module, module_instance and ``` > Note: See [wasm_export.h](../core/iwasm/include/wasm_export.h) for more details. -#### **Enable quick AOT/JTI entries** +### **Enable quick AOT/JTI entries** - **WAMR_BUILD_QUICK_AOT_ENTRY**=1/0, enable registering quick call entries to speedup the aot/jit func call process, default to enable if not set > Note: See [Refine callings to AOT/JIT functions from host native](./perf_tune.md#83-refine-callings-to-aotjit-functions-from-host-native) for more details. -#### **Enable AOT intrinsics** +### **Enable AOT intrinsics** - **WAMR_BUILD_AOT_INTRINSICS**=1/0, enable the AOT intrinsic functions, default to enable if not set. These functions can be called from the AOT code when `--disable-llvm-intrinsics` flag or `--enable-builtin-intrinsics=` flag is used by wamrc to generate the AOT file. > Note: See [Tuning the XIP intrinsic functions](./xip.md#tuning-the-xip-intrinsic-functions) for more details. -#### **Configurable memory access boundary check** +### **Configurable memory access boundary check** - **WAMR_CONFIGURABLE_BOUNDS_CHECKS**=1/0, default to disable if not set > Note: If it is enabled, allow to run `iwasm --disable-bounds-checks` to disable the memory access boundary checks for interpreter mode. -#### **Module instance context APIs** +### **Module instance context APIs** - **WAMR_BUILD_MODULE_INST_CONTEXT**=1/0, default to disable if not set > Note: If it is enabled, allow to set one or more contexts created by embedder for a module instance, the below APIs are provided: ```C @@ -300,7 +300,7 @@ Currently we only profile the memory consumption of module, module_instance and wasm_runtime_get_context ``` -#### **Shared heap among wasm apps and host native** +### **Shared heap among wasm apps and host native** - **WAMR_BUILD_SHARED_HEAP**=1/0, default to disable if not set > Note: If it is enabled, allow to create one or more shared heaps, and attach one to a module instance, the belows APIs ared provided: ```C @@ -316,7 +316,11 @@ And the wasm app can calls below APIs to allocate/free memory from/to the shared void shared_heap_free(void *ptr); ``` -**Combination of configurations:** +### **Shrunk the memory usage** +- **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. + +## **Combination of configurations:** We can combine the configurations. For example, if we want to disable interpreter, enable AOT and WASI, we can run command: @@ -328,4 +332,4 @@ 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 diff --git a/doc/memory_tune.md b/doc/memory_tune.md index 9bb4f6a101..77c7d433f6 100644 --- a/doc/memory_tune.md +++ b/doc/memory_tune.md @@ -32,3 +32,4 @@ Normally there are some methods to tune the memory usage: - use XIP mode, refer to [WAMR XIP (Execution In Place) feature introduction](./xip.md) for more details - when using the Wasm C API in fast interpreter or AOT mode, set `clone_wasm_binary=false` in `LoadArgs` and free the wasm binary buffer (with `wasm_byte_vec_delete`) after module loading; `wasm_module_is_underlying_binary_freeable` can be queried to check if the wasm binary buffer can be safely freed (see [the example](../samples/basic/src/free_buffer_early.c)); after the buffer is freed, `wasm_runtime_get_custom_section` cannot be called anymore - when using the wasm/AOT loader in fast interpreter or AOT mode, set `wasm_binary_freeable=true` in `LoadArgs` and free the wasm binary buffer (with `wasm_byte_vec_delete`) after module loading; `wasm_runtime_is_underlying_binary_freeable` can be queried to check if the wasm binary buffer can be safely freed; after the buffer is freed, `wasm_runtime_get_custom_section` cannot be called anymore +- `WAMR_BUILD_SHRUNK_MEMORY` can be used to reduce the memory usage of WAMR, but it might affect the standard expected behavior of WAMR. \ No newline at end of file diff --git a/tests/wamr-test-suites/spec-test-script/ignore_cases.patch b/tests/wamr-test-suites/spec-test-script/ignore_cases.patch index 73f749737c..e0bcf362e4 100644 --- a/tests/wamr-test-suites/spec-test-script/ignore_cases.patch +++ b/tests/wamr-test-suites/spec-test-script/ignore_cases.patch @@ -1,136 +1,66 @@ -diff --git a/test/core/data.wast b/test/core/data.wast -index b1e1239..a0f6967 100644 ---- a/test/core/data.wast -+++ b/test/core/data.wast -@@ -312,7 +312,8 @@ - "\02\01\41\00\0b" ;; active data segment 0 for memory 1 - "\00" ;; empty vec(byte) - ) -- "unknown memory 1" -+ ;; TODO: restore after supporting multi memory" -+ "unknown memory" - ) - - ;; Data segment with memory index 0 (no memory section) -@@ -334,7 +335,8 @@ - "\02\01\41\00\0b" ;; active data segment 0 for memory 1 - "\00" ;; empty vec(byte) - ) -- "unknown memory 1" -+ ;; TODO: restore after supporting multi memory" -+ "unknown memory" - ) - - ;; Data segment with memory index 1 and vec(byte) as above, -@@ -354,7 +356,8 @@ - "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" - "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" - ) -- "unknown memory 1" -+ ;; TODO: restore after supporting multi memory" -+ "unknown memory" - ) - - ;; Data segment with memory index 1 and specially crafted vec(byte) after. -@@ -374,7 +377,8 @@ - "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" - "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" - ) -- "unknown memory 1" -+ ;; TODO: restore after supporting multi memory" -+ "unknown memory" - ) - - diff --git a/test/core/elem.wast b/test/core/elem.wast -index 33b3f67..a4c1a2d 100644 +index 68a244b..a42cbd4 100644 --- a/test/core/elem.wast +++ b/test/core/elem.wast -@@ -586,6 +586,7 @@ - (assert_return (invoke $module1 "call-8") (i32.const 65)) - (assert_return (invoke $module1 "call-9") (i32.const 66)) - -+(; - (module $module2 - (type $out-i32 (func (result i32))) - (import "module1" "shared-table" (table 10 funcref)) -@@ -598,7 +599,9 @@ - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 68)) - (assert_return (invoke $module1 "call-9") (i32.const 66)) -+;) - -+(; - (module $module3 - (type $out-i32 (func (result i32))) - (import "module1" "shared-table" (table 10 funcref)) -@@ -611,6 +614,7 @@ - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 69)) - (assert_return (invoke $module1 "call-9") (i32.const 70)) -+;) - - ;; Element segments must match element type of table - -@@ -643,6 +647,7 @@ - - ;; Initializing a table with an externref-type element segment - -+(; - (module $m - (table $t (export "table") 2 externref) - (func (export "get") (param $i i32) (result externref) -@@ -667,9 +672,11 @@ - - (assert_return (invoke $m "get" (i32.const 0)) (ref.null extern)) - (assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137)) -+;) - - ;; Initializing a table with imported funcref global - -+(; - (module $module4 - (func (result i32) - i32.const 42 -@@ -690,3 +697,4 @@ +@@ -560,6 +560,9 @@ + ) + (assert_return (invoke "call-overwritten-element") (i32.const 66)) + ++(;; FIXME: enable the following cases after supporting the import of tables ++ ;; ++ + ;; Element sections across multiple modules change the same table + + (module $module1 +@@ -690,3 +693,5 @@ ) (assert_return (invoke "call_imported_elem") (i32.const 42)) -+;) -diff --git a/test/core/if.wast b/test/core/if.wast -index 2ea45f6..6f07304 100644 ---- a/test/core/if.wast -+++ b/test/core/if.wast -@@ -530,7 +530,10 @@ - (func (export "atypical-condition") - i32.const 0 - (if (then) (else)) -- (if (i32.const 1) (i32.eqz) (then) (else)) -+ ;; restore after wabt(> 1.34.0) supports it -+ (i32.const 1) -+ (i32.eqz) -+ (if (then) (else)) - ) ++;; ++;;) +diff --git a/test/core/memory_grow.wast b/test/core/memory_grow.wast +index 882e4b5..d17a509 100644 +--- a/test/core/memory_grow.wast ++++ b/test/core/memory_grow.wast +@@ -308,7 +308,8 @@ + + (assert_return (invoke "as-memory.grow-size") (i32.const 1)) + +- ++(;; FIXME: enable the following cases after supporting the import of memories ++ ;; + (module $Mgm + (memory (export "memory") 1) ;; initial size is 1 + (func (export "grow") (result i32) (memory.grow (i32.const 1))) +@@ -328,7 +329,8 @@ + (func (export "size") (result i32) (memory.size)) ) + (assert_return (invoke $Mgim2 "size") (i32.const 3)) +- ++;; ++;;) + (assert_invalid + (module diff --git a/test/core/ref_func.wast b/test/core/ref_func.wast -index adb5cb7..6396013 100644 +index adb5cb7..98e02cd 100644 --- a/test/core/ref_func.wast +++ b/test/core/ref_func.wast -@@ -4,7 +4,7 @@ +@@ -4,7 +4,8 @@ (register "M") (module - (func $f (import "M" "f") (param i32) (result i32)) ++ (;;FIXME: change it back after supporting the import by default ;;) + (func $f (param $x i32) (result i32) (local.get $x)) (func $g (param $x i32) (result i32) (i32.add (local.get $x) (i32.const 1)) ) diff --git a/test/core/table_copy.wast b/test/core/table_copy.wast -index 380e84e..59230cf 100644 +index 380e84e..2ac9fdc 100644 --- a/test/core/table_copy.wast +++ b/test/core/table_copy.wast -@@ -14,11 +14,11 @@ +@@ -14,11 +14,12 @@ (module (type (func (result i32))) ;; type #0 @@ -139,6 +69,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -147,7 +78,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -106,11 +106,11 @@ +@@ -106,11 +107,12 @@ (module (type (func (result i32))) ;; type #0 @@ -156,6 +87,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -164,7 +96,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -198,11 +198,11 @@ +@@ -198,11 +200,12 @@ (module (type (func (result i32))) ;; type #0 @@ -173,6 +105,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -181,7 +114,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -290,11 +290,11 @@ +@@ -290,11 +293,12 @@ (module (type (func (result i32))) ;; type #0 @@ -190,6 +123,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -198,7 +132,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -382,11 +382,11 @@ +@@ -382,11 +386,12 @@ (module (type (func (result i32))) ;; type #0 @@ -207,6 +141,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -215,7 +150,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -474,11 +474,11 @@ +@@ -474,11 +479,12 @@ (module (type (func (result i32))) ;; type #0 @@ -224,6 +159,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -232,7 +168,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -566,11 +566,11 @@ +@@ -566,11 +572,12 @@ (module (type (func (result i32))) ;; type #0 @@ -241,6 +177,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -249,7 +186,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -658,11 +658,11 @@ +@@ -658,11 +665,12 @@ (module (type (func (result i32))) ;; type #0 @@ -258,6 +195,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -266,7 +204,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -750,11 +750,11 @@ +@@ -750,11 +758,12 @@ (module (type (func (result i32))) ;; type #0 @@ -275,6 +213,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -283,7 +222,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -842,11 +842,11 @@ +@@ -842,11 +851,12 @@ (module (type (func (result i32))) ;; type #0 @@ -292,6 +231,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -300,7 +240,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -934,11 +934,11 @@ +@@ -934,11 +944,12 @@ (module (type (func (result i32))) ;; type #0 @@ -309,6 +249,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -317,7 +258,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1026,11 +1026,11 @@ +@@ -1026,11 +1037,12 @@ (module (type (func (result i32))) ;; type #0 @@ -326,6 +267,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -334,7 +276,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1118,11 +1118,11 @@ +@@ -1118,11 +1130,12 @@ (module (type (func (result i32))) ;; type #0 @@ -343,6 +285,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -351,7 +294,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1210,11 +1210,11 @@ +@@ -1210,11 +1223,12 @@ (module (type (func (result i32))) ;; type #0 @@ -360,6 +303,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -368,7 +312,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1302,11 +1302,11 @@ +@@ -1302,11 +1316,12 @@ (module (type (func (result i32))) ;; type #0 @@ -377,6 +321,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -385,7 +330,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1394,11 +1394,11 @@ +@@ -1394,11 +1409,12 @@ (module (type (func (result i32))) ;; type #0 @@ -394,6 +339,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -402,7 +348,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1486,11 +1486,11 @@ +@@ -1486,11 +1502,12 @@ (module (type (func (result i32))) ;; type #0 @@ -411,6 +357,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -419,7 +366,7 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1578,11 +1578,11 @@ +@@ -1578,11 +1595,12 @@ (module (type (func (result i32))) ;; type #0 @@ -428,6 +375,7 @@ index 380e84e..59230cf 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 ++ (;;FIXME: change it back after supporting the import of tables ;;) + (func (result i32) (i32.const 0)) ;; index 0 + (func (result i32) (i32.const 1)) + (func (result i32) (i32.const 2)) @@ -436,6 +384,29 @@ index 380e84e..59230cf 100644 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) +diff --git a/test/core/table_grow.wast b/test/core/table_grow.wast +index 5345a80..0636f67 100644 +--- a/test/core/table_grow.wast ++++ b/test/core/table_grow.wast +@@ -108,6 +108,8 @@ + (assert_return (invoke "check-table-null" (i32.const 0) (i32.const 19)) (ref.null func)) + + ++(;; FIXME: enable the following cases after supporting the import of tables ++ ;; + (module $Tgt + (table (export "table") 1 funcref) ;; initial size is 1 + (func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1))) +@@ -127,7 +129,8 @@ + (func (export "size") (result i32) (table.size)) + ) + (assert_return (invoke $Tgit2 "size") (i32.const 3)) +- ++;; ++;;) + + ;; Type errors + diff --git a/test/core/table_init.wast b/test/core/table_init.wast index 0b2d26f..3c595e5 100644 --- a/test/core/table_init.wast diff --git a/tests/wamr-test-suites/spec-test-script/multi_module_ignore_cases.patch b/tests/wamr-test-suites/spec-test-script/multi_module_ignore_cases.patch index 9f908488e4..3ff4966d11 100644 --- a/tests/wamr-test-suites/spec-test-script/multi_module_ignore_cases.patch +++ b/tests/wamr-test-suites/spec-test-script/multi_module_ignore_cases.patch @@ -1,56 +1,3 @@ -diff --git a/test/core/imports.wast b/test/core/imports.wast -index 0cc07cb..4e8367a 100644 ---- a/test/core/imports.wast -+++ b/test/core/imports.wast -@@ -86,7 +86,7 @@ - (assert_return (invoke "print64" (i64.const 24))) - - (assert_invalid -- (module -+ (module - (type (func (result i32))) - (import "test" "func" (func (type 1))) - ) -@@ -578,6 +578,7 @@ - (assert_return (invoke "grow" (i32.const 1)) (i32.const -1)) - (assert_return (invoke "grow" (i32.const 0)) (i32.const 2)) - -+(; - (module $Mgm - (memory (export "memory") 1) ;; initial size is 1 - (func (export "grow") (result i32) (memory.grow (i32.const 1))) -@@ -586,7 +587,7 @@ - (assert_return (invoke $Mgm "grow") (i32.const 1)) ;; now size is 2 - (module $Mgim1 - ;; imported memory limits should match, because external memory size is 2 now -- (memory (export "memory") (import "grown-memory" "memory") 2) -+ (memory (export "memory") (import "grown-memory" "memory") 2) - (func (export "grow") (result i32) (memory.grow (i32.const 1))) - ) - (register "grown-imported-memory" $Mgim1) -@@ -597,7 +598,7 @@ - (func (export "size") (result i32) (memory.size)) - ) - (assert_return (invoke $Mgim2 "size") (i32.const 3)) -- -+;) - - ;; Syntax errors - -@@ -669,6 +670,7 @@ - "import after memory" - ) - -+(; - ;; This module is required to validate, regardless of whether it can be - ;; linked. Overloading is not possible in wasm itself, but it is possible - ;; in modules from which wasm can import. -@@ -695,3 +697,4 @@ - ) - "unknown import" - ) -+;) -\ No newline at end of file diff --git a/test/core/linking.wast b/test/core/linking.wast index 994e0f4..8fbcc02 100644 --- a/test/core/linking.wast diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 97820eaad6..6e963bdc74 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -1103,7 +1103,8 @@ def compile_wast_to_wasm(form, wast_tempfile, wasm_tempfile, opts): elif opts.multi_memory: cmd = [opts.wast2wasm, "--enable-multi-memory", "--no-check", wast_tempfile, "-o", wasm_tempfile ] else: - cmd = [opts.wast2wasm, "--enable-threads", "--no-check", + # `--enable-multi-memory` for a case in memory.wast but doesn't require runtime support + cmd = [opts.wast2wasm, "--enable-multi-memory", "--enable-threads", "--no-check", wast_tempfile, "-o", wasm_tempfile ] # remove reference-type and bulk-memory enabling options since a WABT diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 70a8b687cb..64abd9f35f 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -269,16 +269,12 @@ readonly WAMRC_CMD_DEFAULT="${WAMR_DIR}/wamr-compiler/build/wamrc" readonly CLASSIC_INTERP_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0" readonly FAST_INTERP_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0" # jit: report linking error if set COLLECT_CODE_COVERAGE, # now we don't collect code coverage of jit type @@ -286,39 +282,29 @@ readonly ORC_EAGER_JIT_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_LAZY_JIT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_LAZY_JIT=0" readonly ORC_LAZY_JIT_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_LAZY_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_LAZY_JIT=1" readonly AOT_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1" readonly FAST_JIT_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_FAST_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_FAST_JIT=1" readonly MULTI_TIER_JIT_COMPILE_FLAGS="\ -DWAMR_BUILD_TARGET=${TARGET} \ -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1" readonly COMPILE_FLAGS=( "${CLASSIC_INTERP_COMPILE_FLAGS}" @@ -525,8 +511,8 @@ function spec_test() git clone -b main --single-branch https://github.com/WebAssembly/spec pushd spec - # Apr 3, 2024 [js-api] Integrate with the ResizableArrayBuffer proposal (#1300) - git reset --hard bc76fd79cfe61033d7f4ad4a7e8fc4f996dc5ba8 + # 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 if [[ ${ENABLE_SIMD} == 1 ]]; then git apply ../../spec-test-script/simd_ignore_cases.patch || exit 1 @@ -833,7 +819,9 @@ function build_wamrc() && ./${BUILD_LLVM_SH} \ && if [ -d build ]; then rm -r build/*; else mkdir build; fi \ && cd build \ - && cmake .. -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} \ + && cmake .. \ + -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} \ + -DWAMR_BUILD_SHRUNK_MEMORY=0 \ && make -j 4 } @@ -962,6 +950,11 @@ function trigger() fi local EXTRA_COMPILE_FLAGS="" + # for spec test + EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SPEC_TEST=1" + EXTRA_COMPILE_FLAGS+=" -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" + EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SHRUNK_MEMORY=0" + # default enabled features EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1" EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1" diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index ab98b03825..bc56f40308 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -238,6 +238,12 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS) set (WAMR_BUILD_LIB_WASI_THREADS 1) endif () +# Enable by default +if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY) + set (WAMR_BUILD_SHRUNK_MEMORY 1) +endif () +add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=${WAMR_BUILD_SHRUNK_MEMORY}) + if (WAMR_BUILD_LIBC_UVWASI EQUAL 1) message ("-- Libc WASI enabled with uvwasi implementation") endif () From 0d20521406c554e44f8bba7182477f14f7074461 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:30:28 +0800 Subject: [PATCH 062/431] build(deps): Bump actions/upload-artifact from 4.5.0 to 4.6.0 (#4021) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... 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 1da37a4c30..67022b510f 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.5.0 + uses: actions/upload-artifact@v4.6.0 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 7f11695835..2cf80d743e 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -350,7 +350,7 @@ jobs: - name: upload the log if: always() - uses: actions/upload-artifact@v4.5.0 + uses: actions/upload-artifact@v4.6.0 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 425eda532e..e5f2be4af0 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@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v3.1.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v3.1.0 with: name: SARIF file path: results.sarif From 946430f15e0f1182f493806e80ee3a14503628bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:36:50 +0800 Subject: [PATCH 063/431] build(deps): Bump github/codeql-action from 3.28.0 to 3.28.1 (#4020) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.0 to 3.28.1. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.0...v3.28.1) --- 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 67022b510f..753322fcc1 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.0 + uses: github/codeql-action/init@v3.28.1 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.0 + uses: github/codeql-action/analyze@v3.28.1 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.0 + uses: github/codeql-action/upload-sarif@v3.28.1 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 e5f2be4af0..39f2f98351 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@78760076e3f08852c2c3aeb5334f70d074e28c59 # v2.2.4 + uses: github/codeql-action/upload-sarif@db7177a1c66bea89f5e7ce32d0ea48bea4a0d460 # v2.2.4 with: sarif_file: results.sarif From 9c3807e124d6f7eb26d7a93dcc24d16e8ce0afce Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 14 Jan 2025 17:43:29 +0800 Subject: [PATCH 064/431] Refine read leb int wasm loader of fast interpreter (#4017) --- core/iwasm/interpreter/wasm_loader.c | 216 +++++++++++++++------- core/iwasm/interpreter/wasm_mini_loader.c | 148 +++++++++++---- 2 files changed, 262 insertions(+), 102 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 12f4aff75e..4ee553e0b7 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -197,7 +197,6 @@ check_buf1(const uint8 *buf, const uint8 *buf_end, uint32 length, res = (int32)res64; \ } while (0) -#define read_leb_memidx(p, p_end, res) read_leb_uint32(p, p_end, res) #if WASM_ENABLE_MULTI_MEMORY != 0 #define check_memidx(module, memidx) \ do { \ @@ -10924,6 +10923,83 @@ DEFINE_GOTO_TABLE(const char *, op_mnemonics); #undef HANDLE_OPCODE #endif +#if WASM_ENABLE_FAST_INTERP == 0 + +#define pb_read_leb_uint32 read_leb_uint32 +#define pb_read_leb_int32 read_leb_int32 +#define pb_read_leb_int64 read_leb_int64 +#define pb_read_leb_memarg read_leb_memarg +#define pb_read_leb_mem_offset read_leb_mem_offset + +#else + +/* Read leb without malformed format check */ +static uint64 +read_leb_quick(uint8 **p_buf, uint32 maxbits, bool sign) +{ + uint8 *buf = *p_buf; + uint64 result = 0, byte = 0; + uint32 shift = 0; + + do { + byte = *buf++; + result |= ((byte & 0x7f) << shift); + shift += 7; + } while (byte & 0x80); + + if (sign && (shift < maxbits) && (byte & 0x40)) { + /* Sign extend */ + result |= (~((uint64)0)) << shift; + } + + *p_buf = buf; + return result; +} + +#define pb_read_leb_uint32(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_uint32(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (uint32)read_leb_quick(&p, 32, false); \ + } while (0) + +#define pb_read_leb_int32(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_int32(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (int32)read_leb_quick(&p, 32, true); \ + } while (0) + +#define pb_read_leb_int64(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_int64(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (int64)read_leb_quick(&p, 64, true); \ + } while (0) + +#if WASM_ENABLE_MULTI_MEMORY != 0 +#define pb_read_leb_memarg read_leb_memarg +#else +#define pb_read_leb_memarg pb_read_leb_uint32 +#endif + +#if WASM_ENABLE_MEMORY64 != 0 +#define pb_read_leb_mem_offset read_leb_mem_offset +#else +#define pb_read_leb_mem_offset pb_read_leb_uint32 +#endif + +#endif /* end of WASM_ENABLE_FAST_INTERP != 0 */ + static bool wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 cur_func_idx, char *error_buf, @@ -11153,7 +11229,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Resolve the leb128 encoded type index as block type */ p--; p_org = p - 1; - read_leb_int32(p, p_end, type_index); + 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"); @@ -11362,7 +11438,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 label_type = cur_block->label_type; uint32 tag_index = 0; - read_leb_int32(p, p_end, tag_index); + pb_read_leb_int32(p, p_end, tag_index); /* check validity of tag_index against module->tag_count */ /* check tag index is within the tag index space */ @@ -11506,7 +11582,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 label_type = cur_block->label_type; uint32 tag_index = 0; - read_leb_int32(p, p_end, tag_index); + pb_read_leb_int32(p, p_end, tag_index); /* check validity of tag_index against module->tag_count */ /* check tag index is within the tag index space */ @@ -11773,7 +11849,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 j; #endif - read_leb_uint32(p, p_end, count); + pb_read_leb_uint32(p, p_end, count); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, count); #endif @@ -11782,7 +11858,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Get each depth and check it */ p_org = p; for (i = 0; i <= count; i++) { - read_leb_uint32(p, p_end, depth); + pb_read_leb_uint32(p, p_end, depth); bh_assert(loader_ctx->csp_num > 0); if (loader_ctx->csp_num - 1 < depth) { set_error_buf(error_buf, error_buf_size, @@ -11804,7 +11880,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif for (i = 0; i <= count; i++) { p_org = p; - read_leb_uint32(p, p_end, depth); + pb_read_leb_uint32(p, p_end, depth); p = p_org; /* Get the target block's arity and check it */ @@ -11938,7 +12014,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_GC != 0 if (opcode == WASM_OP_CALL_REF || opcode == WASM_OP_RETURN_CALL_REF) { - read_leb_uint32(p, p_end, type_idx1); + pb_read_leb_uint32(p, p_end, type_idx1); if (!check_type_index(module, module->type_count, type_idx1, error_buf, error_buf_size)) { goto fail; @@ -11977,7 +12053,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, else #endif { - read_leb_uint32(p, p_end, func_idx); + pb_read_leb_uint32(p, p_end, func_idx); #if WASM_ENABLE_FAST_INTERP != 0 /* we need to emit func_idx before arguments */ emit_uint32(loader_ctx, func_idx); @@ -12113,7 +12189,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMRefType *elem_ref_type = NULL; #endif - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_WAMR_COMPILER != 0 if (p + 1 < p_end && *p != 0x00) { @@ -12125,7 +12201,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, module->is_ref_types_used = true; } #endif - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); #else CHECK_BUF(p, p_end, 1); table_idx = read_uint8(p); @@ -12444,7 +12520,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled; #endif - read_leb_uint32(p, p_end, vec_len); + pb_read_leb_uint32(p, p_end, vec_len); if (vec_len != 1) { /* typed select must have exactly one result */ set_error_buf(error_buf, error_buf_size, @@ -12574,7 +12650,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMRefType *ref_type; #endif - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &decl_ref_type, #if WASM_ENABLE_GC != 0 (void **)&ref_type, @@ -12635,7 +12711,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, goto fail; } #else - read_leb_int32(p, p_end, heap_type); + pb_read_leb_int32(p, p_end, heap_type); if (heap_type >= 0) { if (!check_type_index(module, module->type_count, heap_type, error_buf, error_buf_size)) { @@ -12722,7 +12798,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_REF_FUNC: { - read_leb_uint32(p, p_end, func_idx); + pb_read_leb_uint32(p, p_end, func_idx); if (!check_function_index(module, func_idx, error_buf, error_buf_size)) { @@ -13118,7 +13194,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif p_org = p - 1; - read_leb_uint32(p, p_end, global_idx); + pb_read_leb_uint32(p, p_end, global_idx); if (global_idx >= global_count) { set_error_buf(error_buf, error_buf_size, "unknown global"); goto fail; @@ -13178,7 +13254,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif p_org = p - 1; - read_leb_uint32(p, p_end, global_idx); + pb_read_leb_uint32(p, p_end, global_idx); if (global_idx >= global_count) { set_error_buf(error_buf, error_buf_size, "unknown global"); goto fail; @@ -13313,8 +13389,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } #endif CHECK_MEMORY(); - read_leb_memarg(p, p_end, align); /* align */ - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_memarg(p, p_end, align); /* align */ + pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ if (!check_memory_access_align(opcode, align, error_buf, error_buf_size)) { goto fail; @@ -13379,7 +13455,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_SIZE: CHECK_MEMORY(); - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); PUSH_PAGE_COUNT(); @@ -13391,7 +13467,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_GROW: CHECK_MEMORY(); - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); POP_AND_PUSH(mem_offset_type, mem_offset_type); @@ -13406,7 +13482,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_I32_CONST: - read_leb_int32(p, p_end, i32_const); + pb_read_leb_int32(p, p_end, i32_const); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); disable_emit = true; @@ -13424,7 +13500,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_I64_CONST: - read_leb_int64(p, p_end, i64_const); + pb_read_leb_int64(p, p_end, i64_const); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); disable_emit = true; @@ -13707,7 +13783,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, ((uint8)opcode1)); #endif @@ -13716,7 +13792,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_STRUCT_NEW: case WASM_OP_STRUCT_NEW_DEFAULT: { - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif @@ -13803,7 +13879,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 field_idx; uint8 field_type; - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif @@ -13820,7 +13896,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } struct_type = (WASMStructType *)module->types[type_idx]; - read_leb_uint32(p, p_end, field_idx); + pb_read_leb_uint32(p, p_end, field_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, field_idx); #endif @@ -13896,14 +13972,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 elem_type; uint32 u32 = 0; - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif if (opcode1 == WASM_OP_ARRAY_NEW_FIXED || opcode1 == WASM_OP_ARRAY_NEW_DATA || opcode1 == WASM_OP_ARRAY_NEW_ELEM) { - read_leb_uint32(p, p_end, u32); + pb_read_leb_uint32(p, p_end, u32); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, u32); #endif @@ -14006,7 +14082,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMArrayType *array_type; WASMRefType *ref_type = NULL; - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif @@ -14078,7 +14154,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMArrayType *array_type; uint8 elem_type; /* typeidx */ - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif @@ -14124,12 +14200,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMArrayType *array_type; /* typeidx1 */ - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, type_idx); #endif /* typeidx2 */ - read_leb_uint32(p, p_end, src_type_idx); + pb_read_leb_uint32(p, p_end, src_type_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, src_type_idx); #endif @@ -14216,7 +14292,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint8 type; - read_leb_int32(p, p_end, heap_type); + pb_read_leb_int32(p, p_end, heap_type); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)heap_type); #endif @@ -14277,13 +14353,13 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif p_org = p; - read_leb_uint32(p, p_end, depth); - read_leb_int32(p, p_end, heap_type); + pb_read_leb_uint32(p, p_end, depth); + pb_read_leb_int32(p, p_end, heap_type); #if WASM_ENABLE_FAST_INTERP != 0 /* Emit heap_type firstly */ emit_uint32(loader_ctx, (uint32)heap_type); #endif - read_leb_int32(p, p_end, heap_type_dst); + pb_read_leb_int32(p, p_end, heap_type_dst); #if WASM_ENABLE_FAST_INTERP != 0 /* Emit heap_type firstly */ emit_uint32(loader_ctx, (uint32)heap_type_dst); @@ -14485,7 +14561,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, func->has_memory_operations = true; #endif - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)memidx); #endif @@ -14499,7 +14575,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 contents; - read_leb_uint32(p, p_end, contents); + pb_read_leb_uint32(p, p_end, contents); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)contents); #endif @@ -14526,7 +14602,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, func->has_memory_operations = true; #endif - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)memidx); #endif @@ -14580,7 +14656,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, func->has_memory_operations = true; #endif - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)memidx); #endif @@ -14628,7 +14704,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, func->has_memory_operations = true; #endif - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, (uint32)memidx); #endif @@ -14712,7 +14788,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, ((uint8)opcode1)); #endif @@ -14736,7 +14812,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_BULK_MEMORY != 0 case WASM_OP_MEMORY_INIT: { - read_leb_uint32(p, p_end, data_seg_idx); + pb_read_leb_uint32(p, p_end, data_seg_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, data_seg_idx); #endif @@ -14744,7 +14820,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, && module->memory_count == 0) goto fail_unknown_memory; - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); if (data_seg_idx >= module->data_seg_count) { @@ -14770,7 +14846,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_DATA_DROP: { - read_leb_uint32(p, p_end, data_seg_idx); + pb_read_leb_uint32(p, p_end, data_seg_idx); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, data_seg_idx); #endif @@ -14795,9 +14871,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { CHECK_BUF(p, p_end, sizeof(int16)); /* check both src and dst memory index */ - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); if (module->import_memory_count == 0 @@ -14817,7 +14893,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_MEMORY_FILL: { - read_leb_uint32(p, p_end, memidx); + pb_read_leb_uint32(p, p_end, memidx); check_memidx(module, memidx); if (module->import_memory_count == 0 && module->memory_count == 0) { @@ -14852,8 +14928,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMRefType *seg_ref_type = NULL, *tbl_ref_type = NULL; #endif - read_leb_uint32(p, p_end, table_seg_idx); - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_seg_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &tbl_type, #if WASM_ENABLE_GC != 0 @@ -14910,7 +14986,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_ELEM_DROP: { - read_leb_uint32(p, p_end, table_seg_idx); + pb_read_leb_uint32(p, p_end, table_seg_idx); if (!get_table_seg_elem_type(module, table_seg_idx, NULL, NULL, error_buf, error_buf_size)) @@ -14933,7 +15009,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif uint32 src_tbl_idx, dst_tbl_idx; - read_leb_uint32(p, p_end, dst_tbl_idx); + pb_read_leb_uint32(p, p_end, dst_tbl_idx); if (!get_table_elem_type(module, dst_tbl_idx, &dst_type, #if WASM_ENABLE_GC != 0 (void **)&dst_ref_type, @@ -14943,7 +15019,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, error_buf, error_buf_size)) goto fail; - read_leb_uint32(p, p_end, src_tbl_idx); + pb_read_leb_uint32(p, p_end, src_tbl_idx); if (!get_table_elem_type(module, src_tbl_idx, &src_type, #if WASM_ENABLE_GC != 0 (void **)&src_ref_type, @@ -15006,7 +15082,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_TABLE_SIZE: { - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); /* TODO: shall we create a new function to check table idx instead of using below function? */ if (!get_table_elem_type(module, table_idx, NULL, NULL, @@ -15037,7 +15113,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, WASMRefType *ref_type = NULL; #endif - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &decl_type, #if WASM_ENABLE_GC != 0 (void **)&ref_type, @@ -15112,7 +15188,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, module->is_simd_used = true; #endif - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); /* follow the order of enum WASMSimdEXTOpcode in wasm_opcode.h */ @@ -15132,13 +15208,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_uint32(p, p_end, align); /* align */ if (!check_simd_memory_access_align( opcode1, align, error_buf, error_buf_size)) { goto fail; } - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_mem_offset(p, p_end, + mem_offset); /* offset */ POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 @@ -15151,13 +15228,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_uint32(p, p_end, align); /* align */ if (!check_simd_memory_access_align( opcode1, align, error_buf, error_buf_size)) { goto fail; } - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_mem_offset(p, p_end, + mem_offset); /* offset */ POP_V128(); POP_MEM_OFFSET(); @@ -15369,13 +15447,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_uint32(p, p_end, align); /* align */ if (!check_simd_memory_access_align( opcode1, align, error_buf, error_buf_size)) { goto fail; } - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_mem_offset(p, p_end, + mem_offset); /* offset */ CHECK_BUF(p, p_end, 1); lane = read_uint8(p); @@ -15400,13 +15479,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_uint32(p, p_end, align); /* align */ if (!check_simd_memory_access_align( opcode1, align, error_buf, error_buf_size)) { goto fail; } - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_mem_offset(p, p_end, + mem_offset); /* offset */ POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 @@ -15764,15 +15844,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, opcode1); #endif if (opcode1 != WASM_OP_ATOMIC_FENCE) { CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ if (!check_memory_align_equal(opcode1, align, error_buf, error_buf_size)) { goto fail; diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index df4d818a39..fde969c944 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -6048,6 +6048,86 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, char *error_buf, } \ } while (0) +#if WASM_ENABLE_FAST_INTERP == 0 + +#define pb_read_leb_uint32 read_leb_uint32 +#define pb_read_leb_int32 read_leb_int32 +#define pb_read_leb_int64 read_leb_int64 +#define pb_read_leb_memarg read_leb_memarg +#define pb_read_leb_mem_offset read_leb_mem_offset +#define pb_read_leb_memidx read_leb_memidx + +#else + +/* Read leb without malformed format check */ +static uint64 +read_leb_quick(uint8 **p_buf, uint32 maxbits, bool sign) +{ + uint8 *buf = *p_buf; + uint64 result = 0, byte = 0; + uint32 shift = 0; + + do { + byte = *buf++; + result |= ((byte & 0x7f) << shift); + shift += 7; + } while (byte & 0x80); + + if (sign && (shift < maxbits) && (byte & 0x40)) { + /* Sign extend */ + result |= (~((uint64)0)) << shift; + } + + *p_buf = buf; + return result; +} + +#define pb_read_leb_uint32(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_uint32(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (uint32)read_leb_quick(&p, 32, false); \ + } while (0) + +#define pb_read_leb_int32(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_int32(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (int32)read_leb_quick(&p, 32, true); \ + } while (0) + +#define pb_read_leb_int64(p, p_end, res) \ + do { \ + if (!loader_ctx->p_code_compiled) \ + /* Enable format check in the first scan */ \ + read_leb_int64(p, p_end, res); \ + else \ + /* Disable format check in the second scan */ \ + res = (int64)read_leb_quick(&p, 64, true); \ + } while (0) + +#if WASM_ENABLE_MULTI_MEMORY != 0 +#define pb_read_leb_memarg read_leb_memarg +#else +#define pb_read_leb_memarg pb_read_leb_uint32 +#endif + +#if WASM_ENABLE_MEMORY64 != 0 +#define pb_read_leb_mem_offset read_leb_mem_offset +#else +#define pb_read_leb_mem_offset pb_read_leb_uint32 +#endif + +#define pb_read_leb_memidx pb_read_leb_uint32 + +#endif /* end of WASM_ENABLE_FAST_INTERP != 0 */ + static bool wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 cur_func_idx, char *error_buf, @@ -6195,7 +6275,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, int32 type_index; /* Resolve the leb128 encoded type index as block type */ p--; - read_leb_int32(p, p_end, type_index); + pb_read_leb_int32(p, p_end, type_index); bh_assert((uint32)type_index < module->type_count); block_type.is_value_type = false; block_type.u.type = module->types[type_index]; @@ -6508,7 +6588,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 j; #endif - read_leb_uint32(p, p_end, count); + pb_read_leb_uint32(p, p_end, count); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, count); #endif @@ -6517,7 +6597,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Get each depth and check it */ p_org = p; for (i = 0; i <= count; i++) { - read_leb_uint32(p, p_end, depth); + pb_read_leb_uint32(p, p_end, depth); bh_assert(loader_ctx->csp_num > 0); bh_assert(loader_ctx->csp_num - 1 >= depth); (void)depth; @@ -6615,7 +6695,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 func_idx; int32 idx; - read_leb_uint32(p, p_end, func_idx); + pb_read_leb_uint32(p, p_end, func_idx); #if WASM_ENABLE_FAST_INTERP != 0 /* we need to emit func_idx before arguments */ emit_uint32(loader_ctx, func_idx); @@ -6688,10 +6768,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, bh_assert(module->import_table_count + module->table_count > 0); - read_leb_uint32(p, p_end, type_idx); + pb_read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_REF_TYPES != 0 - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); #else CHECK_BUF(p, p_end, 1); table_idx = read_uint8(p); @@ -6931,7 +7011,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled; #endif - read_leb_uint32(p, p_end, vec_len); + pb_read_leb_uint32(p, p_end, vec_len); if (vec_len != 1) { /* typed select must have exactly one result */ set_error_buf(error_buf, error_buf_size, @@ -7006,7 +7086,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 decl_ref_type; uint32 table_idx; - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &decl_ref_type, error_buf, error_buf_size)) goto fail; @@ -7100,7 +7180,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_REF_FUNC: { uint32 func_idx = 0; - read_leb_uint32(p, p_end, func_idx); + pb_read_leb_uint32(p, p_end, func_idx); if (!check_function_index(module, func_idx, error_buf, error_buf_size)) { @@ -7317,7 +7397,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_GET_GLOBAL: { p_org = p - 1; - read_leb_uint32(p, p_end, global_idx); + pb_read_leb_uint32(p, p_end, global_idx); bh_assert(global_idx < global_count); global_type = global_idx < module->import_global_count @@ -7351,7 +7431,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, bool is_mutable = false; p_org = p - 1; - read_leb_uint32(p, p_end, global_idx); + pb_read_leb_uint32(p, p_end, global_idx); bh_assert(global_idx < global_count); is_mutable = global_idx < module->import_global_count @@ -7448,8 +7528,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } #endif CHECK_MEMORY(); - read_leb_memarg(p, p_end, align); /* align */ - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_memarg(p, p_end, align); /* align */ + pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, mem_offset); #endif @@ -7510,7 +7590,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_SIZE: CHECK_MEMORY(); - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); PUSH_PAGE_COUNT(); @@ -7522,7 +7602,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_GROW: CHECK_MEMORY(); - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); POP_AND_PUSH(mem_offset_type, mem_offset_type); @@ -7537,7 +7617,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_I32_CONST: - read_leb_int32(p, p_end, i32_const); + pb_read_leb_int32(p, p_end, i32_const); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); disable_emit = true; @@ -7555,7 +7635,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_I64_CONST: - read_leb_int64(p, p_end, i64_const); + pb_read_leb_int64(p, p_end, i64_const); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); disable_emit = true; @@ -7837,7 +7917,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, ((uint8)opcode1)); #endif @@ -7862,11 +7942,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_INIT: { CHECK_MEMORY(); - read_leb_uint32(p, p_end, segment_index); + pb_read_leb_uint32(p, p_end, segment_index); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, segment_index); #endif - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); bh_assert(segment_index < module->data_seg_count); @@ -7882,7 +7962,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_DATA_DROP: { - read_leb_uint32(p, p_end, segment_index); + pb_read_leb_uint32(p, p_end, segment_index); #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, segment_index); #endif @@ -7898,9 +7978,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, CHECK_MEMORY(); CHECK_BUF(p, p_end, sizeof(int16)); /* check both src and dst memory index */ - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); POP_MEM_OFFSET(); @@ -7914,7 +7994,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_MEMORY_FILL: { CHECK_MEMORY(); - read_leb_memidx(p, p_end, memidx); + pb_read_leb_memidx(p, p_end, memidx); check_memidx(module, memidx); POP_MEM_OFFSET(); @@ -7932,8 +8012,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 seg_ref_type, tbl_ref_type; uint32 table_seg_idx, table_idx; - read_leb_uint32(p, p_end, table_seg_idx); - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_seg_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &tbl_ref_type, error_buf, @@ -7968,7 +8048,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_ELEM_DROP: { uint32 table_seg_idx; - read_leb_uint32(p, p_end, table_seg_idx); + pb_read_leb_uint32(p, p_end, table_seg_idx); if (!get_table_seg_elem_type(module, table_seg_idx, NULL, error_buf, error_buf_size)) @@ -7984,13 +8064,13 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 src_tbl_idx, dst_tbl_idx, src_tbl_idx_type, dst_tbl_idx_type, min_tbl_idx_type; - read_leb_uint32(p, p_end, src_tbl_idx); + pb_read_leb_uint32(p, p_end, src_tbl_idx); if (!get_table_elem_type(module, src_tbl_idx, &src_ref_type, error_buf, error_buf_size)) goto fail; - read_leb_uint32(p, p_end, dst_tbl_idx); + pb_read_leb_uint32(p, p_end, dst_tbl_idx); if (!get_table_elem_type(module, dst_tbl_idx, &dst_ref_type, error_buf, error_buf_size)) @@ -8037,7 +8117,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 table_idx; - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); /* TODO: shall we create a new function to check table idx instead of using below function? */ if (!get_table_elem_type(module, table_idx, NULL, @@ -8062,7 +8142,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 decl_ref_type; uint32 table_idx; - read_leb_uint32(p, p_end, table_idx); + pb_read_leb_uint32(p, p_end, table_idx); if (!get_table_elem_type(module, table_idx, &decl_ref_type, error_buf, error_buf_size)) @@ -8114,15 +8194,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - read_leb_uint32(p, p_end, opcode1); + pb_read_leb_uint32(p, p_end, opcode1); #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, opcode1); #endif if (opcode1 != WASM_OP_ATOMIC_FENCE) { CHECK_MEMORY(); - read_leb_uint32(p, p_end, align); /* align */ - read_leb_mem_offset(p, p_end, mem_offset); /* offset */ + pb_read_leb_uint32(p, p_end, align); /* align */ + pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ #if WASM_ENABLE_FAST_INTERP != 0 emit_uint32(loader_ctx, mem_offset); #endif From 1ac62e1f22ab28789d8611dae9a51b1580cb3ad3 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo <90845888+midokura-xavi92@users.noreply.github.com> Date: Wed, 15 Jan 2025 08:14:22 +0100 Subject: [PATCH 065/431] .github: Add shared lib builds (#3975) So far, no workflows would attempt to build the shared version of the iwasm library (namely, vmlib). Note that, as opposed to GC_EH_BUILD_OPTIONS and DEFAULT_BUILD_OPTIONS, the actual default options defined by the build system are assumed, for the sake of simplicity and avoiding repeated code. --- .github/workflows/compilation_on_android_ubuntu.yml | 4 ++++ .github/workflows/nightly_run.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 1ea36418e5..119c8b2d05 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -156,6 +156,7 @@ jobs: "-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_BUILD_MEMORY64=1", "-DWAMR_BUILD_MULTI_MEMORY=1", + "-DWAMR_BUILD_SHARED=1", ] os: [ubuntu-22.04] platform: [android, linux] @@ -253,6 +254,9 @@ jobs: platform: android - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS platform: android + # android does not support WAMR_BUILD_SHARED in its CMakeLists.txt. + - make_options_feature: "-DWAMR_BUILD_SHARED=1" + platform: android include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index 5e9b4a4f29..dacdbc42d7 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -142,6 +142,7 @@ jobs: "-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_BUILD_MEMORY64=1", "-DWAMR_BUILD_MULTI_MEMORY=1", + "-DWAMR_BUILD_SHARED=1", ] os: [ubuntu-20.04] platform: [android, linux] From ba75b8fd563d041009fed4c910fc886dbb31c68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Mal=C3=BD?= Date: Fri, 17 Jan 2025 04:06:14 +0100 Subject: [PATCH 066/431] fixes for compiling on windows (#4026) --- core/shared/platform/windows/win_clock.c | 16 +++++++++++++--- core/shared/platform/windows/win_thread.c | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/core/shared/platform/windows/win_clock.c b/core/shared/platform/windows/win_clock.c index c402330aad..1d618c8b67 100644 --- a/core/shared/platform/windows/win_clock.c +++ b/core/shared/platform/windows/win_clock.c @@ -11,9 +11,19 @@ #define NANOSECONDS_PER_TICK 100 #if WINAPI_PARTITION_DESKTOP -extern NTSTATUS -NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution, - PULONG CurrentResolution); +#ifndef __kernel_entry +#define __kernel_entry +#endif +#ifndef NTAPI +#define NTAPI +#endif +#ifndef _Out_ +#define _Out_ +#endif +extern __kernel_entry NTSTATUS NTAPI +NtQueryTimerResolution(_Out_ PULONG MinimumResolution, + _Out_ PULONG MaximumResolution, + _Out_ PULONG CurrentResolution); #endif static __wasi_errno_t diff --git a/core/shared/platform/windows/win_thread.c b/core/shared/platform/windows/win_thread.c index 438e160405..1f6a57ebbf 100644 --- a/core/shared/platform/windows/win_thread.c +++ b/core/shared/platform/windows/win_thread.c @@ -60,6 +60,17 @@ static DWORD thread_data_key; static void(WINAPI *GetCurrentThreadStackLimits_Kernel32)(PULONG_PTR, PULONG_PTR) = NULL; +int +os_sem_init(korp_sem *sem); +int +os_sem_destroy(korp_sem *sem); +int +os_sem_wait(korp_sem *sem); +int +os_sem_reltimed_wait(korp_sem *sem, uint64 useconds); +int +os_sem_signal(korp_sem *sem); + static void thread_data_list_add(os_thread_data *thread_data) { @@ -117,17 +128,6 @@ thread_data_list_lookup(korp_tid tid) return NULL; } -int -os_sem_init(korp_sem *sem); -int -os_sem_destroy(korp_sem *sem); -int -os_sem_wait(korp_sem *sem); -int -os_sem_reltimed_wait(korp_sem *sem, uint64 useconds); -int -os_sem_signal(korp_sem *sem); - int os_thread_sys_init() { From 68e4534822d1f1ccf353831e64853e221fd0bd77 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Fri, 17 Jan 2025 16:16:45 +0000 Subject: [PATCH 067/431] 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 0f7b5d3d9a..87f0775ecc 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 297b2a5b5d..5405772c90 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 5517fe60fc..b631a9e114 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 4c7dfed4f7..6157c64317 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 273657246d..cf75eeb6cc 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 1416405460..a4e31766d2 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 834311f7ea..2d4eb82d99 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 f44644e456..f61b24f7cd 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 c3f35916cd..529e0a2fcb 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 00e9ad107f..7322bb16c3 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 831e4bbfd51323e10e47db1d5f7200341e87a6bb Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 20 Jan 2025 09:39:32 +0800 Subject: [PATCH 068/431] Refine getting const offsets in wasm loader of fast-interp (#4012) - Refine const offsets in loader for fast-interp - handle const cell num overflow - Use const array, remove list --- core/iwasm/interpreter/wasm_loader.c | 332 ++++++++++++--------- core/iwasm/interpreter/wasm_mini_loader.c | 334 +++++++++++++--------- 2 files changed, 409 insertions(+), 257 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 4ee553e0b7..6cd1ece4fe 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -355,9 +355,14 @@ memory_realloc(void *mem_old, uint32 size_old, uint32 size_new, char *error_buf, { uint8 *mem_new; bh_assert(size_new > size_old); + + if ((mem_new = wasm_runtime_realloc(mem_old, size_new))) { + memset(mem_new + size_old, 0, size_new - size_old); + return mem_new; + } + if ((mem_new = loader_malloc(size_new, error_buf, error_buf_size))) { bh_memcpy_s(mem_new, size_new, mem_old, size_old); - memset(mem_new + size_old, 0, size_new - size_old); wasm_runtime_free(mem_old); } return mem_new; @@ -7949,11 +7954,16 @@ typedef struct WASMLoaderContext { /* preserved local offset */ int16 preserved_local_offset; - /* const buffer */ - uint8 *const_buf; - uint16 num_const; - uint16 const_cell_num; - uint32 const_buf_size; + /* const buffer for i64 and f64 consts, note that the raw bytes + * of i64 and f64 are the same, so we read an i64 value from an + * f64 const with its raw bytes, something like `*(int64 *)&f64 */ + int64 *i64_consts; + uint32 i64_const_max_num; + uint32 i64_const_num; + /* const buffer for i32 and f32 consts */ + int32 *i32_consts; + uint32 i32_const_max_num; + uint32 i32_const_num; /* processed code */ uint8 *p_code_compiled; @@ -7966,12 +7976,6 @@ typedef struct WASMLoaderContext { #endif } WASMLoaderContext; -typedef struct Const { - WASMValue value; - uint16 slot_index; - uint8 value_type; -} Const; - #define CHECK_CSP_PUSH() \ do { \ if (ctx->frame_csp >= ctx->frame_csp_boundary) { \ @@ -8189,8 +8193,10 @@ wasm_loader_ctx_destroy(WASMLoaderContext *ctx) #if WASM_ENABLE_FAST_INTERP != 0 if (ctx->frame_offset_bottom) wasm_runtime_free(ctx->frame_offset_bottom); - if (ctx->const_buf) - wasm_runtime_free(ctx->const_buf); + if (ctx->i64_consts) + wasm_runtime_free(ctx->i64_consts); + if (ctx->i32_consts) + wasm_runtime_free(ctx->i32_consts); #endif wasm_runtime_free(ctx); } @@ -8238,10 +8244,15 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size) goto fail; loader_ctx->frame_offset_boundary = loader_ctx->frame_offset_bottom + 32; - loader_ctx->num_const = 0; - loader_ctx->const_buf_size = sizeof(Const) * 8; - if (!(loader_ctx->const_buf = loader_malloc(loader_ctx->const_buf_size, - error_buf, error_buf_size))) + loader_ctx->i64_const_max_num = 8; + if (!(loader_ctx->i64_consts = + loader_malloc(sizeof(int64) * loader_ctx->i64_const_max_num, + error_buf, error_buf_size))) + goto fail; + loader_ctx->i32_const_max_num = 8; + if (!(loader_ctx->i32_consts = + loader_malloc(sizeof(int32) * loader_ctx->i32_const_max_num, + error_buf, error_buf_size))) goto fail; if (func->param_cell_num >= (int32)INT16_MAX - func->local_cell_num) { @@ -9489,108 +9500,116 @@ wasm_loader_push_pop_frame_ref_offset(WASMLoaderContext *ctx, uint8 pop_cnt, return true; } +static int +cmp_i64_const(const void *p_i64_const1, const void *p_i64_const2) +{ + int64 i64_const1 = *(int64 *)p_i64_const1; + int64 i64_const2 = *(int64 *)p_i64_const2; + + return (i64_const1 < i64_const2) ? -1 : (i64_const1 > i64_const2) ? 1 : 0; +} + +static int +cmp_i32_const(const void *p_i32_const1, const void *p_i32_const2) +{ + int32 i32_const1 = *(int32 *)p_i32_const1; + int32 i32_const2 = *(int32 *)p_i32_const2; + + return (i32_const1 < i32_const2) ? -1 : (i32_const1 > i32_const2) ? 1 : 0; +} + static bool wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, int16 *offset, char *error_buf, uint32 error_buf_size) { - int8 bytes_to_increase; - int16 operand_offset = 0; - Const *c; - - /* Search existing constant */ - for (c = (Const *)ctx->const_buf; - (uint8 *)c < ctx->const_buf + ctx->num_const * sizeof(Const); c++) { - /* TODO: handle v128 type? */ - if ((type == c->value_type) - && ((type == VALUE_TYPE_I64 && *(int64 *)value == c->value.i64) - || (type == VALUE_TYPE_I32 && *(int32 *)value == c->value.i32) -#if WASM_ENABLE_REF_TYPES != 0 && WASM_ENABLE_GC == 0 - || (type == VALUE_TYPE_FUNCREF - && *(int32 *)value == c->value.i32) - || (type == VALUE_TYPE_EXTERNREF - && *(int32 *)value == c->value.i32) -#endif - || (type == VALUE_TYPE_F64 - && (0 == memcmp(value, &(c->value.f64), sizeof(float64)))) - || (type == VALUE_TYPE_F32 - && (0 - == memcmp(value, &(c->value.f32), sizeof(float32)))))) { - operand_offset = c->slot_index; - break; - } - if (is_32bit_type(c->value_type)) - operand_offset += 1; - else - operand_offset += 2; - } + if (!ctx->p_code_compiled) { + /* Treat i64 and f64 as the same by reading i64 value from + the raw bytes */ + if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) { + /* No slot left, emit const instead */ + if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 2) { + *offset = 0; + return true; + } + + /* Traverse the list if the const num is small */ + if (ctx->i64_const_num < 10) { + for (uint32 i = 0; i < ctx->i64_const_num; i++) { + if (ctx->i64_consts[i] == *(int64 *)value) { + *offset = -1; + return true; + } + } + } - if ((uint8 *)c == ctx->const_buf + ctx->num_const * sizeof(Const)) { - /* New constant, append to the const buffer */ - if ((type == VALUE_TYPE_F64) || (type == VALUE_TYPE_I64)) { - bytes_to_increase = 2; + if (ctx->i64_const_num >= ctx->i64_const_max_num) { + MEM_REALLOC(ctx->i64_consts, + sizeof(int64) * ctx->i64_const_max_num, + sizeof(int64) * (ctx->i64_const_max_num * 2)); + ctx->i64_const_max_num *= 2; + } + ctx->i64_consts[ctx->i64_const_num++] = *(int64 *)value; } else { - bytes_to_increase = 1; - } + /* Treat i32 and f32 as the same by reading i32 value from + the raw bytes */ + bh_assert(type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32); - /* The max cell num of const buffer is 32768 since the valid index range - * is -32768 ~ -1. Return an invalid index 0 to indicate the buffer is - * full */ - if (ctx->const_cell_num > INT16_MAX - bytes_to_increase + 1) { - *offset = 0; - return true; + /* No slot left, emit const instead */ + if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 1) { + *offset = 0; + return true; + } + + /* Traverse the list if the const num is small */ + if (ctx->i32_const_num < 10) { + for (uint32 i = 0; i < ctx->i32_const_num; i++) { + if (ctx->i32_consts[i] == *(int32 *)value) { + *offset = -1; + return true; + } + } + } + + if (ctx->i32_const_num >= ctx->i32_const_max_num) { + MEM_REALLOC(ctx->i32_consts, + sizeof(int32) * ctx->i32_const_max_num, + sizeof(int32) * (ctx->i32_const_max_num * 2)); + ctx->i32_const_max_num *= 2; + } + ctx->i32_consts[ctx->i32_const_num++] = *(int32 *)value; } - if ((uint8 *)c == ctx->const_buf + ctx->const_buf_size) { - MEM_REALLOC(ctx->const_buf, ctx->const_buf_size, - ctx->const_buf_size + 4 * sizeof(Const)); - ctx->const_buf_size += 4 * sizeof(Const); - c = (Const *)(ctx->const_buf + ctx->num_const * sizeof(Const)); + *offset = -1; + return true; + } + else { + if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) { + int64 key = *(int64 *)value, *i64_const; + i64_const = bsearch(&key, ctx->i64_consts, ctx->i64_const_num, + sizeof(int64), cmp_i64_const); + if (!i64_const) { /* not found, emit const instead */ + *offset = 0; + return true; + } + *offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num) + + (uint32)(i64_const - ctx->i64_consts) * 2; } - c->value_type = type; - switch (type) { - case VALUE_TYPE_F64: - bh_memcpy_s(&(c->value.f64), sizeof(WASMValue), value, - sizeof(float64)); - ctx->const_cell_num += 2; - /* The const buf will be reversed, we use the second cell */ - /* of the i64/f64 const so the final offset is correct */ - operand_offset++; - break; - case VALUE_TYPE_I64: - c->value.i64 = *(int64 *)value; - ctx->const_cell_num += 2; - operand_offset++; - break; - case VALUE_TYPE_F32: - bh_memcpy_s(&(c->value.f32), sizeof(WASMValue), value, - sizeof(float32)); - ctx->const_cell_num++; - break; - case VALUE_TYPE_I32: - c->value.i32 = *(int32 *)value; - ctx->const_cell_num++; - break; -#if WASM_ENABLE_REF_TYPES != 0 && WASM_ENABLE_GC == 0 - case VALUE_TYPE_EXTERNREF: - case VALUE_TYPE_FUNCREF: - c->value.i32 = *(int32 *)value; - ctx->const_cell_num++; - break; -#endif - default: - break; + else { + int32 key = *(int32 *)value, *i32_const; + i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num, + sizeof(int32), cmp_i32_const); + if (!i32_const) { /* not found, emit const instead */ + *offset = 0; + return true; + } + *offset = -(uint32)(ctx->i32_const_num) + + (uint32)(i32_const - ctx->i32_consts); } - c->slot_index = operand_offset; - ctx->num_const++; - LOG_OP("#### new const [%d]: %ld\n", ctx->num_const, - (int64)c->value.i64); + + return true; } - /* use negative index for const */ - operand_offset = -(operand_offset + 1); - *offset = operand_offset; - return true; fail: return false; } @@ -11028,7 +11047,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, bool need_ref_type_map; #endif #if WASM_ENABLE_FAST_INTERP != 0 - uint8 *func_const_end, *func_const = NULL; int16 operand_offset = 0; uint8 last_op = 0; bool disable_emit, preserve_local = false, if_condition_available = true; @@ -11095,6 +11113,68 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, p = func->code; func->code_compiled = loader_ctx->p_code_compiled; func->code_compiled_size = loader_ctx->code_compiled_size; + + if (loader_ctx->i64_const_num > 0) { + int64 *i64_consts_old = loader_ctx->i64_consts; + + /* Sort the i64 consts */ + qsort(i64_consts_old, loader_ctx->i64_const_num, sizeof(int64), + cmp_i64_const); + + /* Remove the duplicated i64 consts */ + uint32 k = 1; + for (i = 1; i < loader_ctx->i64_const_num; i++) { + if (i64_consts_old[i] != i64_consts_old[i - 1]) { + i64_consts_old[k++] = i64_consts_old[i]; + } + } + + if (k < loader_ctx->i64_const_num) { + int64 *i64_consts_new; + /* Try to reallocate memory with a smaller size */ + if ((i64_consts_new = + wasm_runtime_malloc((uint32)sizeof(int64) * k))) { + bh_memcpy_s(i64_consts_new, (uint32)sizeof(int64) * k, + i64_consts_old, (uint32)sizeof(int64) * k); + /* Free the old memory */ + wasm_runtime_free(i64_consts_old); + loader_ctx->i64_consts = i64_consts_new; + loader_ctx->i64_const_max_num = k; + } + loader_ctx->i64_const_num = k; + } + } + + if (loader_ctx->i32_const_num > 0) { + int32 *i32_consts_old = loader_ctx->i32_consts; + + /* Sort the i32 consts */ + qsort(i32_consts_old, loader_ctx->i32_const_num, sizeof(int32), + cmp_i32_const); + + /* Remove the duplicated i32 consts */ + uint32 k = 1; + for (i = 1; i < loader_ctx->i32_const_num; i++) { + if (i32_consts_old[i] != i32_consts_old[i - 1]) { + i32_consts_old[k++] = i32_consts_old[i]; + } + } + + if (k < loader_ctx->i32_const_num) { + int32 *i32_consts_new; + /* Try to reallocate memory with a smaller size */ + if ((i32_consts_new = + wasm_runtime_malloc((uint32)sizeof(int32) * k))) { + bh_memcpy_s(i32_consts_new, (uint32)sizeof(int32) * k, + i32_consts_old, (uint32)sizeof(int32) * k); + /* Free the old memory */ + wasm_runtime_free(i32_consts_old); + loader_ctx->i32_consts = i32_consts_new; + loader_ctx->i32_const_max_num = k; + } + loader_ctx->i32_const_num = k; + } + } } #endif @@ -16016,29 +16096,25 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (loader_ctx->p_code_compiled == NULL) goto re_scan; - func->const_cell_num = loader_ctx->const_cell_num; + func->const_cell_num = + loader_ctx->i64_const_num * 2 + loader_ctx->i32_const_num; if (func->const_cell_num > 0) { - int32 j; - - if (!(func->consts = func_const = loader_malloc( - func->const_cell_num * 4, error_buf, error_buf_size))) + if (!(func->consts = + loader_malloc((uint64)sizeof(uint32) * func->const_cell_num, + error_buf, error_buf_size))) goto fail; - - func_const_end = func->consts + func->const_cell_num * 4; - /* reverse the const buf */ - for (j = loader_ctx->num_const - 1; j >= 0; j--) { - Const *c = (Const *)(loader_ctx->const_buf + j * sizeof(Const)); - if (c->value_type == VALUE_TYPE_F64 - || c->value_type == VALUE_TYPE_I64) { - bh_memcpy_s(func_const, (uint32)(func_const_end - func_const), - &(c->value.f64), (uint32)sizeof(int64)); - func_const += sizeof(int64); - } - else { - bh_memcpy_s(func_const, (uint32)(func_const_end - func_const), - &(c->value.f32), (uint32)sizeof(int32)); - func_const += sizeof(int32); - } + if (loader_ctx->i64_const_num > 0) { + bh_memcpy_s(func->consts, + (uint32)sizeof(int64) * loader_ctx->i64_const_num, + loader_ctx->i64_consts, + (uint32)sizeof(int64) * loader_ctx->i64_const_num); + } + if (loader_ctx->i32_const_num > 0) { + bh_memcpy_s(func->consts + + sizeof(int64) * loader_ctx->i64_const_num, + (uint32)sizeof(int32) * loader_ctx->i32_const_num, + loader_ctx->i32_consts, + (uint32)sizeof(int32) * loader_ctx->i32_const_num); } } diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index fde969c944..1638459a53 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -208,9 +208,14 @@ memory_realloc(void *mem_old, uint32 size_old, uint32 size_new, char *error_buf, { uint8 *mem_new; bh_assert(size_new > size_old); + + if ((mem_new = wasm_runtime_realloc(mem_old, size_new))) { + memset(mem_new + size_old, 0, size_new - size_old); + return mem_new; + } + if ((mem_new = loader_malloc(size_new, error_buf, error_buf_size))) { bh_memcpy_s(mem_new, size_new, mem_old, size_old); - memset(mem_new + size_old, 0, size_new - size_old); wasm_runtime_free(mem_old); } return mem_new; @@ -4047,11 +4052,16 @@ typedef struct WASMLoaderContext { /* preserved local offset */ int16 preserved_local_offset; - /* const buffer */ - uint8 *const_buf; - uint16 num_const; - uint16 const_cell_num; - uint32 const_buf_size; + /* const buffer for i64 and f64 consts, note that the raw bytes + * of i64 and f64 are the same, so we read an i64 value from an + * f64 const with its raw bytes, something like `*(int64 *)&f64 */ + int64 *i64_consts; + uint32 i64_const_max_num; + uint32 i64_const_num; + /* const buffer for i32 and f32 consts */ + int32 *i32_consts; + uint32 i32_const_max_num; + uint32 i32_const_num; /* processed code */ uint8 *p_code_compiled; @@ -4064,12 +4074,6 @@ typedef struct WASMLoaderContext { #endif } WASMLoaderContext; -typedef struct Const { - WASMValue value; - uint16 slot_index; - uint8 value_type; -} Const; - #define CHECK_CSP_PUSH() \ do { \ if (ctx->frame_csp >= ctx->frame_csp_boundary) { \ @@ -4224,8 +4228,10 @@ wasm_loader_ctx_destroy(WASMLoaderContext *ctx) #if WASM_ENABLE_FAST_INTERP != 0 if (ctx->frame_offset_bottom) wasm_runtime_free(ctx->frame_offset_bottom); - if (ctx->const_buf) - wasm_runtime_free(ctx->const_buf); + if (ctx->i64_consts) + wasm_runtime_free(ctx->i64_consts); + if (ctx->i32_consts) + wasm_runtime_free(ctx->i32_consts); #endif wasm_runtime_free(ctx); } @@ -4259,10 +4265,15 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size) goto fail; loader_ctx->frame_offset_boundary = loader_ctx->frame_offset_bottom + 32; - loader_ctx->num_const = 0; - loader_ctx->const_buf_size = sizeof(Const) * 8; - if (!(loader_ctx->const_buf = loader_malloc(loader_ctx->const_buf_size, - error_buf, error_buf_size))) + loader_ctx->i64_const_max_num = 8; + if (!(loader_ctx->i64_consts = + loader_malloc(sizeof(int64) * loader_ctx->i64_const_max_num, + error_buf, error_buf_size))) + goto fail; + loader_ctx->i32_const_max_num = 8; + if (!(loader_ctx->i32_consts = + loader_malloc(sizeof(int32) * loader_ctx->i32_const_max_num, + error_buf, error_buf_size))) goto fail; if (func->param_cell_num >= (int32)INT16_MAX - func->local_cell_num) { @@ -5085,107 +5096,116 @@ wasm_loader_push_pop_frame_ref_offset(WASMLoaderContext *ctx, uint8 pop_cnt, return true; } +static int +cmp_i64_const(const void *p_i64_const1, const void *p_i64_const2) +{ + int64 i64_const1 = *(int64 *)p_i64_const1; + int64 i64_const2 = *(int64 *)p_i64_const2; + + return (i64_const1 < i64_const2) ? -1 : (i64_const1 > i64_const2) ? 1 : 0; +} + +static int +cmp_i32_const(const void *p_i32_const1, const void *p_i32_const2) +{ + int32 i32_const1 = *(int32 *)p_i32_const1; + int32 i32_const2 = *(int32 *)p_i32_const2; + + return (i32_const1 < i32_const2) ? -1 : (i32_const1 > i32_const2) ? 1 : 0; +} + static bool wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, int16 *offset, char *error_buf, uint32 error_buf_size) { - int8 bytes_to_increase; - int16 operand_offset = 0; - Const *c; - - /* Search existing constant */ - for (c = (Const *)ctx->const_buf; - (uint8 *)c < ctx->const_buf + ctx->num_const * sizeof(Const); c++) { - if ((type == c->value_type) - && ((type == VALUE_TYPE_I64 && *(int64 *)value == c->value.i64) - || (type == VALUE_TYPE_I32 && *(int32 *)value == c->value.i32) -#if WASM_ENABLE_REF_TYPES != 0 - || (type == VALUE_TYPE_FUNCREF - && *(int32 *)value == c->value.i32) - || (type == VALUE_TYPE_EXTERNREF - && *(int32 *)value == c->value.i32) -#endif - || (type == VALUE_TYPE_F64 - && (0 == memcmp(value, &(c->value.f64), sizeof(float64)))) - || (type == VALUE_TYPE_F32 - && (0 - == memcmp(value, &(c->value.f32), sizeof(float32)))))) { - operand_offset = c->slot_index; - break; - } - if (c->value_type == VALUE_TYPE_I64 || c->value_type == VALUE_TYPE_F64) - operand_offset += 2; - else - operand_offset += 1; - } + if (!ctx->p_code_compiled) { + /* Treat i64 and f64 as the same by reading i64 value from + the raw bytes */ + if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) { + /* No slot left, emit const instead */ + if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 2) { + *offset = 0; + return true; + } + + /* Traverse the list if the const num is small */ + if (ctx->i64_const_num < 10) { + for (uint32 i = 0; i < ctx->i64_const_num; i++) { + if (ctx->i64_consts[i] == *(int64 *)value) { + *offset = -1; + return true; + } + } + } - if ((uint8 *)c == ctx->const_buf + ctx->num_const * sizeof(Const)) { - /* New constant, append to the const buffer */ - if ((type == VALUE_TYPE_F64) || (type == VALUE_TYPE_I64)) { - bytes_to_increase = 2; + if (ctx->i64_const_num >= ctx->i64_const_max_num) { + MEM_REALLOC(ctx->i64_consts, + sizeof(int64) * ctx->i64_const_max_num, + sizeof(int64) * (ctx->i64_const_max_num * 2)); + ctx->i64_const_max_num *= 2; + } + ctx->i64_consts[ctx->i64_const_num++] = *(int64 *)value; } else { - bytes_to_increase = 1; - } + /* Treat i32 and f32 as the same by reading i32 value from + the raw bytes */ + bh_assert(type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32); + + /* No slot left, emit const instead */ + if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 1) { + *offset = 0; + return true; + } - /* The max cell num of const buffer is 32768 since the valid index range - * is -32768 ~ -1. Return an invalid index 0 to indicate the buffer is - * full */ - if (ctx->const_cell_num > INT16_MAX - bytes_to_increase + 1) { - *offset = 0; - return true; + /* Traverse the list if the const num is small */ + if (ctx->i32_const_num < 10) { + for (uint32 i = 0; i < ctx->i32_const_num; i++) { + if (ctx->i32_consts[i] == *(int32 *)value) { + *offset = -1; + return true; + } + } + } + + if (ctx->i32_const_num >= ctx->i32_const_max_num) { + MEM_REALLOC(ctx->i32_consts, + sizeof(int32) * ctx->i32_const_max_num, + sizeof(int32) * (ctx->i32_const_max_num * 2)); + ctx->i32_const_max_num *= 2; + } + ctx->i32_consts[ctx->i32_const_num++] = *(int32 *)value; } - if ((uint8 *)c == ctx->const_buf + ctx->const_buf_size) { - MEM_REALLOC(ctx->const_buf, ctx->const_buf_size, - ctx->const_buf_size + 4 * sizeof(Const)); - ctx->const_buf_size += 4 * sizeof(Const); - c = (Const *)(ctx->const_buf + ctx->num_const * sizeof(Const)); + *offset = -1; + return true; + } + else { + if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) { + int64 key = *(int64 *)value, *i64_const; + i64_const = bsearch(&key, ctx->i64_consts, ctx->i64_const_num, + sizeof(int64), cmp_i64_const); + if (!i64_const) { /* not found, emit const instead */ + *offset = 0; + return true; + } + *offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num) + + (uint32)(i64_const - ctx->i64_consts) * 2; } - c->value_type = type; - switch (type) { - case VALUE_TYPE_F64: - bh_memcpy_s(&(c->value.f64), sizeof(WASMValue), value, - sizeof(float64)); - ctx->const_cell_num += 2; - /* The const buf will be reversed, we use the second cell */ - /* of the i64/f64 const so the finnal offset is corrent */ - operand_offset++; - break; - case VALUE_TYPE_I64: - c->value.i64 = *(int64 *)value; - ctx->const_cell_num += 2; - operand_offset++; - break; - case VALUE_TYPE_F32: - bh_memcpy_s(&(c->value.f32), sizeof(WASMValue), value, - sizeof(float32)); - ctx->const_cell_num++; - break; - case VALUE_TYPE_I32: - c->value.i32 = *(int32 *)value; - ctx->const_cell_num++; - break; -#if WASM_ENABLE_REF_TYPES != 0 - case VALUE_TYPE_EXTERNREF: - case VALUE_TYPE_FUNCREF: - c->value.i32 = *(int32 *)value; - ctx->const_cell_num++; - break; -#endif - default: - break; + else { + int32 key = *(int32 *)value, *i32_const; + i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num, + sizeof(int32), cmp_i32_const); + if (!i32_const) { /* not found, emit const instead */ + *offset = 0; + return true; + } + *offset = -(uint32)(ctx->i32_const_num) + + (uint32)(i32_const - ctx->i32_consts); } - c->slot_index = operand_offset; - ctx->num_const++; - LOG_OP("#### new const [%d]: %ld\n", ctx->num_const, - (int64)c->value.i64); - } - /* use negetive index for const */ - operand_offset = -(operand_offset + 1); - *offset = operand_offset; - return true; + + return true; + } fail: return false; } @@ -6151,11 +6171,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint32 segment_index; #endif #if WASM_ENABLE_FAST_INTERP != 0 - uint8 *func_const_end, *func_const = NULL; int16 operand_offset = 0; uint8 last_op = 0; bool disable_emit, preserve_local = false, if_condition_available = true; - ; float32 f32_const; float64 f64_const; @@ -6206,6 +6224,68 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, p = func->code; func->code_compiled = loader_ctx->p_code_compiled; func->code_compiled_size = loader_ctx->code_compiled_size; + + if (loader_ctx->i64_const_num > 0) { + int64 *i64_consts_old = loader_ctx->i64_consts; + + /* Sort the i64 consts */ + qsort(i64_consts_old, loader_ctx->i64_const_num, sizeof(int64), + cmp_i64_const); + + /* Remove the duplicated i64 consts */ + uint32 k = 1; + for (i = 1; i < loader_ctx->i64_const_num; i++) { + if (i64_consts_old[i] != i64_consts_old[i - 1]) { + i64_consts_old[k++] = i64_consts_old[i]; + } + } + + if (k < loader_ctx->i64_const_num) { + int64 *i64_consts_new; + /* Try to reallocate memory with a smaller size */ + if ((i64_consts_new = + wasm_runtime_malloc((uint32)sizeof(int64) * k))) { + bh_memcpy_s(i64_consts_new, (uint32)sizeof(int64) * k, + i64_consts_old, (uint32)sizeof(int64) * k); + /* Free the old memory */ + wasm_runtime_free(i64_consts_old); + loader_ctx->i64_consts = i64_consts_new; + loader_ctx->i64_const_max_num = k; + } + loader_ctx->i64_const_num = k; + } + } + + if (loader_ctx->i32_const_num > 0) { + int32 *i32_consts_old = loader_ctx->i32_consts; + + /* Sort the i32 consts */ + qsort(i32_consts_old, loader_ctx->i32_const_num, sizeof(int32), + cmp_i32_const); + + /* Remove the duplicated i32 consts */ + uint32 k = 1; + for (i = 1; i < loader_ctx->i32_const_num; i++) { + if (i32_consts_old[i] != i32_consts_old[i - 1]) { + i32_consts_old[k++] = i32_consts_old[i]; + } + } + + if (k < loader_ctx->i32_const_num) { + int32 *i32_consts_new; + /* Try to reallocate memory with a smaller size */ + if ((i32_consts_new = + wasm_runtime_malloc((uint32)sizeof(int32) * k))) { + bh_memcpy_s(i32_consts_new, (uint32)sizeof(int32) * k, + i32_consts_old, (uint32)sizeof(int32) * k); + /* Free the old memory */ + wasm_runtime_free(i32_consts_old); + loader_ctx->i32_consts = i32_consts_new; + loader_ctx->i32_const_max_num = k; + } + loader_ctx->i32_const_num = k; + } + } } #endif @@ -8352,29 +8432,25 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (loader_ctx->p_code_compiled == NULL) goto re_scan; - func->const_cell_num = loader_ctx->const_cell_num; + func->const_cell_num = + loader_ctx->i64_const_num * 2 + loader_ctx->i32_const_num; if (func->const_cell_num > 0) { - int32 j; - - if (!(func->consts = func_const = loader_malloc( - func->const_cell_num * 4, error_buf, error_buf_size))) + if (!(func->consts = + loader_malloc((uint64)sizeof(uint32) * func->const_cell_num, + error_buf, error_buf_size))) goto fail; - - func_const_end = func->consts + func->const_cell_num * 4; - /* reverse the const buf */ - for (j = loader_ctx->num_const - 1; j >= 0; j--) { - Const *c = (Const *)(loader_ctx->const_buf + j * sizeof(Const)); - if (c->value_type == VALUE_TYPE_F64 - || c->value_type == VALUE_TYPE_I64) { - bh_memcpy_s(func_const, (uint32)(func_const_end - func_const), - &(c->value.f64), (uint32)sizeof(int64)); - func_const += sizeof(int64); - } - else { - bh_memcpy_s(func_const, (uint32)(func_const_end - func_const), - &(c->value.f32), (uint32)sizeof(int32)); - func_const += sizeof(int32); - } + if (loader_ctx->i64_const_num > 0) { + bh_memcpy_s(func->consts, + (uint32)sizeof(int64) * loader_ctx->i64_const_num, + loader_ctx->i64_consts, + (uint32)sizeof(int64) * loader_ctx->i64_const_num); + } + if (loader_ctx->i32_const_num > 0) { + bh_memcpy_s(func->consts + + sizeof(int64) * loader_ctx->i64_const_num, + (uint32)sizeof(int32) * loader_ctx->i32_const_num, + loader_ctx->i32_consts, + (uint32)sizeof(int32) * loader_ctx->i32_const_num); } } From e3ddbd58f7d35e3ee367679b1b6b61ea8e7839af Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 20 Jan 2025 09:41:47 +0800 Subject: [PATCH 069/431] Synchronize the GC spec tests to the commit from December 9. 2024. (#4022) - Synchronize the GC spec tests to the commit from December 9. 2024. - Revise the error messages to be consistent with the spec test cases. - bypass gc spec test on the nuttx platform as a workaround --- .github/workflows/spec_test_on_nuttx.yml | 3 +- core/iwasm/common/wasm_runtime_common.c | 8 +- core/iwasm/interpreter/wasm_interp_classic.c | 10 +- core/iwasm/interpreter/wasm_interp_fast.c | 10 +- core/iwasm/interpreter/wasm_loader.c | 5 +- core/iwasm/interpreter/wasm_runtime.c | 2 +- .../wamr-test-suites/spec-test-script/all.py | 7 +- .../spec-test-script/gc_ignore_cases.patch | 967 +++++++++--------- .../spec-test-script/gc_nuttx_tail_call.patch | 33 +- tests/wamr-test-suites/test_wamr.sh | 11 +- 10 files changed, 518 insertions(+), 538 deletions(-) diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index 2cf80d743e..8138a86127 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -127,7 +127,8 @@ jobs: wamr_feature_option: # Empty option for default - { option: "", mode: "" } - - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" } + # need to install menhir + # - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" } exclude: # XIP is not fully supported yet on RISCV64, some relocations can not be resolved diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 5517fe60fc..cc6badd9e4 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -3014,9 +3014,9 @@ static const char *exception_msgs[] = { "wasm operand stack overflow", /* EXCE_OPERAND_STACK_OVERFLOW */ "failed to compile fast jit function", /* EXCE_FAILED_TO_COMPILE_FAST_JIT_FUNC */ /* GC related exceptions */ - "null function object", /* EXCE_NULL_FUNC_OBJ */ - "null structure object", /* EXCE_NULL_STRUCT_OBJ */ - "null array reference", /* EXCE_NULL_ARRAY_OBJ */ + "null function reference", /* EXCE_NULL_FUNC_OBJ */ + "null structure reference", /* EXCE_NULL_STRUCT_OBJ */ + "null array reference", /* EXCE_NULL_ARRAY_OBJ */ "null i31 reference", /* EXCE_NULL_I31_OBJ */ "null reference", /* EXCE_NULL_REFERENCE */ "create rtt type failed", /* EXCE_FAILED_TO_CREATE_RTT_TYPE */ @@ -3024,7 +3024,7 @@ static const char *exception_msgs[] = { "create array object failed", /* EXCE_FAILED_TO_CREATE_ARRAY_OBJ */ "create externref object failed", /* EXCE_FAILED_TO_CREATE_EXTERNREF_OBJ */ "cast failure", /* EXCE_CAST_FAILURE */ - "out of bounds array access", /* EXCE_ARRAY_IDX_OOB */ + "out of bounds array access", /* EXCE_ARRAY_IDX_OOB */ /* stringref related exceptions */ "create string object failed", /* EXCE_FAILED_TO_CREATE_STRING */ "create stringref failed", /* EXCE_FAILED_TO_CREATE_STRINGREF */ diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 834311f7ea..98668470fb 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -2649,7 +2649,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, read_leb_uint32(frame_ip, frame_ip_end, type_index); func_obj = POP_REF(); if (!func_obj) { - wasm_set_exception(module, "null function object"); + wasm_set_exception(module, "null function reference"); goto got_exception; } @@ -2666,7 +2666,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, read_leb_uint32(frame_ip, frame_ip_end, type_index); func_obj = POP_REF(); if (!func_obj) { - wasm_set_exception(module, "null function object"); + wasm_set_exception(module, "null function reference"); goto got_exception; } @@ -2813,7 +2813,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, struct_obj = POP_REF(); if (!struct_obj) { - wasm_set_exception(module, "null structure object"); + wasm_set_exception(module, + "null structure reference"); goto got_exception; } @@ -2869,7 +2870,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, struct_obj = POP_REF(); if (!struct_obj) { - wasm_set_exception(module, "null structure object"); + wasm_set_exception(module, + "null structure reference"); goto got_exception; } diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index f44644e456..359a6979c7 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1992,7 +1992,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif func_obj = POP_REF(); if (!func_obj) { - wasm_set_exception(module, "null function object"); + wasm_set_exception(module, "null function reference"); goto got_exception; } @@ -2007,7 +2007,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif func_obj = POP_REF(); if (!func_obj) { - wasm_set_exception(module, "null function object"); + wasm_set_exception(module, "null function reference"); goto got_exception; } @@ -2148,7 +2148,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, struct_obj = POP_REF(); if (!struct_obj) { - wasm_set_exception(module, "null structure object"); + wasm_set_exception(module, + "null structure reference"); goto got_exception; } @@ -2204,7 +2205,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, struct_obj = POP_REF(); if (!struct_obj) { - wasm_set_exception(module, "null structure object"); + wasm_set_exception(module, + "null structure reference"); goto got_exception; } diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 6cd1ece4fe..d495ba63ef 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -2139,8 +2139,9 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, if (!wasm_type_is_subtype_of(cur_type, parent_type, module->types, module->type_count)) { - set_error_buf(error_buf, error_buf_size, - "sub type does not match super type"); + set_error_buf_v(error_buf, error_buf_size, + "sub type %u does not match super type", + processed_type_count + j); return false; } } diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index c3f35916cd..18c56417e7 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4660,7 +4660,7 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx, if (!(func_obj = wasm_create_func_obj(module_inst, init_values[i].u.ref_index, true, NULL, 0))) { - wasm_set_exception(module_inst, "null function object"); + wasm_set_exception(module_inst, "null function reference"); return; } table_elems[i] = func_obj; diff --git a/tests/wamr-test-suites/spec-test-script/all.py b/tests/wamr-test-suites/spec-test-script/all.py index 005874eee3..fe694124ad 100644 --- a/tests/wamr-test-suites/spec-test-script/all.py +++ b/tests/wamr-test-suites/spec-test-script/all.py @@ -100,7 +100,12 @@ def ignore_the_case( return True if gc_flag: - if case_name in ["array_init_elem", "array_init_data"]: + if case_name in [ + "array_init_elem", + "array_init_data", + "array_new_data", + "array_new_elem" + ]: return True if sgx_flag: diff --git a/tests/wamr-test-suites/spec-test-script/gc_ignore_cases.patch b/tests/wamr-test-suites/spec-test-script/gc_ignore_cases.patch index bc91d6b065..e333dd933e 100644 --- a/tests/wamr-test-suites/spec-test-script/gc_ignore_cases.patch +++ b/tests/wamr-test-suites/spec-test-script/gc_ignore_cases.patch @@ -1,417 +1,332 @@ -diff --git a/test/core/binary-leb128.wast b/test/core/binary-leb128.wast -index 335496f0..5b975028 100644 ---- a/test/core/binary-leb128.wast -+++ b/test/core/binary-leb128.wast -@@ -1078,5 +1078,5 @@ - "\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding - "\00\00" - ) -- "integer representation too long" -+ "invalid type flag" ;; In GC extension, the first byte in rectype define is just one byte, not LEB128 encoded. - ) -diff --git a/test/core/elem.wast b/test/core/elem.wast -index df1610f6..32c1d8b3 100644 ---- a/test/core/elem.wast -+++ b/test/core/elem.wast -@@ -400,7 +400,7 @@ +diff --git a/test/core/br_if.wast b/test/core/br_if.wast +index 9d0cdd81..19902310 100644 +--- a/test/core/br_if.wast ++++ b/test/core/br_if.wast +@@ -663,6 +663,7 @@ + "unknown label" ) ++(;; Activate the test case once the capability to manage such edge cases is enabled. + ;; https://github.com/WebAssembly/gc/issues/516 (assert_invalid -- (module -+ (module - (table 1 funcref) - (elem (offset (;empty instruction sequence;))) + (module +@@ -677,3 +678,4 @@ ) -@@ -476,7 +476,7 @@ + "type mismatch" ) - ++;;) +diff --git a/test/core/br_on_non_null.wast b/test/core/br_on_non_null.wast +index 43800194..b9bb5c41 100644 +--- a/test/core/br_on_non_null.wast ++++ b/test/core/br_on_non_null.wast +@@ -72,7 +72,8 @@ + (assert_return (invoke "args-null" (i32.const 3)) (i32.const 3)) + (assert_return (invoke "args-f" (i32.const 3)) (i32.const 9)) + +- ++(;;Activate the test case once the capability to manage such edge cases is enabled. ++;; ASSERTION FAILED: 0, at file /workspaces/wasm-micro-runtime/core/iwasm/common/gc/gc_type.c, line 1059 + ;; https://github.com/WebAssembly/gc/issues/516 (assert_invalid -- (module -+ (module - (table 1 funcref) - (elem (global.get 0)) - ) -@@ -493,7 +493,7 @@ + (module +@@ -88,3 +89,4 @@ + ) + "type mismatch" ) - - (assert_invalid -- (module -+ (module - (global (import "test" "global-mut-i32") (mut i32)) - (table 1 funcref) - (elem (global.get 0)) -@@ -603,12 +603,13 @@ ++;;) +diff --git a/test/core/br_on_null.wast b/test/core/br_on_null.wast +index e47dae50..58abf6a9 100644 +--- a/test/core/br_on_null.wast ++++ b/test/core/br_on_null.wast +@@ -66,6 +66,7 @@ + (assert_return (invoke "args-f" (i32.const 3)) (i32.const 9)) + + ++(;; Activate the test case once the capability to manage such edge cases is enabled. + ;; https://github.com/WebAssembly/gc/issues/516 + ;; Tests that validators are correctly doing + ;; +@@ -92,3 +93,4 @@ ) + "type mismatch" + ) ++;;) +diff --git a/test/core/elem.wast b/test/core/elem.wast +index bc1cc324..14af14ae 100644 +--- a/test/core/elem.wast ++++ b/test/core/elem.wast +@@ -462,6 +462,7 @@ + "\02\00\0b" ;; Function 0: empty ) --(register "module1" $module1) -+(; (register "module1" $module1) ;) ++(;; Enable the case once compatibility has been established. + (module + (func) + (table 1 (ref func) (ref.func 0)) +@@ -478,6 +479,7 @@ + "\0a\04\01" ;; Code section: 1 function + "\02\00\0b" ;; Function 0: empty + ) ++;;) --(assert_trap (invoke $module1 "call-7") "uninitialized element") --(assert_return (invoke $module1 "call-8") (i32.const 65)) --(assert_return (invoke $module1 "call-9") (i32.const 66)) -+(assert_trap (invoke "call-7") "uninitialized element") -+(assert_return (invoke "call-8") (i32.const 65)) -+(assert_return (invoke "call-9") (i32.const 66)) + (module + (func) +@@ -536,6 +538,7 @@ + "type mismatch" + ) -+(; - (module $module2 - (type $out-i32 (func (result i32))) - (import "module1" "shared-table" (table 10 funcref)) -@@ -617,11 +618,15 @@ - (func $const-i32-c (type $out-i32) (i32.const 67)) - (func $const-i32-d (type $out-i32) (i32.const 68)) ++(;; Enable the case once compatibility has been established. + (module + (func) + (table 1 (ref func) (ref.func 0)) +@@ -552,6 +555,7 @@ + "\0a\04\01" ;; Code section: 1 function + "\02\00\0b" ;; Function 0: empty ) -+;) ++;;) + + (module + (func) +@@ -929,8 +933,9 @@ + (assert_return (invoke "call-overwritten-element") (i32.const 66)) -+(; - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 68)) - (assert_return (invoke $module1 "call-9") (i32.const 66)) -+;) -+(; - (module $module3 ++(;;Activate test cases once the capability to import table is enabled ++;; + ;; Element sections across multiple modules change the same table +- + (module $module1 (type $out-i32 (func (result i32))) - (import "module1" "shared-table" (table 10 funcref)) -@@ -634,6 +639,7 @@ + (table (export "shared-table") 10 funcref) +@@ -980,6 +985,7 @@ (assert_return (invoke $module1 "call-7") (i32.const 67)) (assert_return (invoke $module1 "call-8") (i32.const 69)) (assert_return (invoke $module1 "call-9") (i32.const 70)) -+;) ++;;) ;; Element segments must match element type of table -@@ -666,6 +672,7 @@ +@@ -1019,17 +1025,18 @@ + (func (export "set") (param $i i32) (param $x externref) + (table.set $t (local.get $i) (local.get $x)))) + +-(register "exporter" $m) ++;; (register "exporter" $m) - ;; Initializing a table with an externref-type element segment +-(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern)) +-(assert_return (invoke $m "get" (i32.const 1)) (ref.null extern)) ++(assert_return (invoke "get" (i32.const 0)) (ref.null extern)) ++(assert_return (invoke "get" (i32.const 1)) (ref.null extern)) -+(; - (module $m - (table $t (export "table") 2 externref) - (func (export "get") (param $i i32) (result externref) -@@ -713,3 +720,5 @@ +-(assert_return (invoke $m "set" (i32.const 0) (ref.extern 42))) +-(assert_return (invoke $m "set" (i32.const 1) (ref.extern 137))) ++(assert_return (invoke "set" (i32.const 0) (ref.extern 42))) ++(assert_return (invoke "set" (i32.const 1) (ref.extern 137))) + +-(assert_return (invoke $m "get" (i32.const 0)) (ref.extern 42)) +-(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137)) ++(assert_return (invoke "get" (i32.const 0)) (ref.extern 42)) ++(assert_return (invoke "get" (i32.const 1)) (ref.extern 137)) + ++(;;Activate test cases once the capability to import table is enabled + (module + (import "exporter" "table" (table $t 2 externref)) + (elem (i32.const 0) externref (ref.null extern))) +@@ -1059,3 +1066,4 @@ ) (assert_return (invoke "call_imported_elem") (i32.const 42)) -+ -+;) ++;;) diff --git a/test/core/gc/array.wast b/test/core/gc/array.wast -index f5888cb2..b4a2dc0a 100644 +index 6ad95c08..a184435d 100644 --- a/test/core/gc/array.wast +++ b/test/core/gc/array.wast -@@ -95,7 +95,7 @@ +@@ -95,7 +95,10 @@ ) (assert_return (invoke "new") (ref.array)) -(assert_return (invoke "new") (ref.eq)) ++(; Activate once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +;; (assert_return (invoke "new") (ref.eq)) (assert_return (invoke "get" (i32.const 0)) (f32.const 0)) (assert_return (invoke "set_get" (i32.const 1) (f32.const 7)) (f32.const 7)) (assert_return (invoke "len") (i32.const 3)) -@@ -140,7 +140,7 @@ +@@ -140,7 +143,10 @@ ) (assert_return (invoke "new") (ref.array)) -(assert_return (invoke "new") (ref.eq)) ++(; Activate once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +;; (assert_return (invoke "new") (ref.eq)) (assert_return (invoke "get" (i32.const 0)) (f32.const 1)) (assert_return (invoke "set_get" (i32.const 1) (f32.const 7)) (f32.const 7)) (assert_return (invoke "len") (i32.const 2)) -@@ -185,7 +185,7 @@ +@@ -192,7 +198,10 @@ ) (assert_return (invoke "new") (ref.array)) -(assert_return (invoke "new") (ref.eq)) ++(; Activate once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +;; (assert_return (invoke "new") (ref.eq)) - (assert_return (invoke "get" (i32.const 0)) (i32.const 1)) + (assert_return (invoke "get_u" (i32.const 2)) (i32.const 0xff)) + (assert_return (invoke "get_s" (i32.const 2)) (i32.const -1)) (assert_return (invoke "set_get" (i32.const 1) (i32.const 7)) (i32.const 7)) - (assert_return (invoke "len") (i32.const 3)) -@@ -193,6 +193,7 @@ - (assert_trap (invoke "get" (i32.const 10)) "out of bounds array access") +@@ -202,6 +211,7 @@ + (assert_trap (invoke "get_s" (i32.const 10)) "out of bounds array access") (assert_trap (invoke "set_get" (i32.const 10) (i32.const 7)) "out of bounds array access") -+(; array.new_elem not supported ++(;; Activate once aligned `array.new_elem` (module (type $bvec (array i8)) (type $vec (array (ref $bvec))) -@@ -251,6 +252,7 @@ +@@ -260,6 +270,7 @@ (assert_trap (invoke "get" (i32.const 10) (i32.const 0)) "out of bounds array access") (assert_trap (invoke "set_get" (i32.const 10) (i32.const 0) (i32.const 0)) "out of bounds array access") -+;) ++;;) + + (assert_invalid + (module +diff --git a/test/core/gc/br_on_cast.wast b/test/core/gc/br_on_cast.wast +index 3c895c07..147f9a1a 100644 +--- a/test/core/gc/br_on_cast.wast ++++ b/test/core/gc/br_on_cast.wast +@@ -267,6 +267,7 @@ + ) + + ++(;;Activate the test case once the capability to manage such edge cases is enabled. + ;; https://github.com/WebAssembly/gc/issues/516 + (assert_invalid + (module +@@ -283,3 +284,4 @@ + ) + "type mismatch" + ) ++;;) +diff --git a/test/core/gc/br_on_cast_fail.wast b/test/core/gc/br_on_cast_fail.wast +index db6db11b..b0224c84 100644 +--- a/test/core/gc/br_on_cast_fail.wast ++++ b/test/core/gc/br_on_cast_fail.wast +@@ -282,6 +282,7 @@ + ) + ++(;;Activate the test case once the capability to manage such edge cases is enabled. + ;; https://github.com/WebAssembly/gc/issues/516 (assert_invalid (module +@@ -298,3 +299,4 @@ + ) + "type mismatch" + ) ++;;) diff --git a/test/core/gc/extern.wast b/test/core/gc/extern.wast -index abf31669..9ef86506 100644 +index abf31669..4243808d 100644 --- a/test/core/gc/extern.wast +++ b/test/core/gc/extern.wast -@@ -43,7 +43,7 @@ +@@ -43,7 +43,10 @@ (assert_return (invoke "externalize-i" (i32.const 1)) (ref.extern)) (assert_return (invoke "externalize-i" (i32.const 2)) (ref.extern)) (assert_return (invoke "externalize-i" (i32.const 3)) (ref.extern)) -(assert_return (invoke "externalize-i" (i32.const 4)) (ref.extern)) ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +(assert_return (invoke "externalize-i" (i32.const 4)) (ref.extern 0)) (assert_return (invoke "externalize-i" (i32.const 5)) (ref.null extern)) (assert_return (invoke "externalize-ii" (i32.const 0)) (ref.null any)) -diff --git a/test/core/gc/initializer.wast b/test/core/gc/initializer.wast -new file mode 100644 -index 00000000..32650644 ---- /dev/null -+++ b/test/core/gc/initializer.wast -@@ -0,0 +1,34 @@ -+;; added cases to test constant expressions -+ -+(module -+ (type $struct (struct (field f32) (field $y (mut f32)) (field $z f32))) -+ (type $vec (array f32)) -+ -+ ;; table initializer -+ (table 10 anyref) -+ -+ ;; global initializer -+ (global (ref $vec) (array.new_fixed $vec 2 (f32.const 1) (f32.const 2))) -+ (global (ref $struct) (struct.new_default $struct)) -+ -+ ;; elem initializer -+ (elem (i32.const 0) (ref $vec) (array.new_default $vec (i32.const 2))) -+ (elem (i32.const 1) (ref $vec) (array.new $vec (f32.const 1) (i32.const 3))) -+ (elem (i32.const 2) (ref $struct) (struct.new_default $struct)) -+ -+ (func (export "get_table") (param $i i32) (result anyref) -+ (table.get (local.get $i)) -+ ) -+) -+ -+(assert_return (invoke "get_table" (i32.const 0)) (ref.array)) -+(assert_return (invoke "get_table" (i32.const 1)) (ref.array)) -+(assert_return (invoke "get_table" (i32.const 2)) (ref.struct)) -+ -+(assert_invalid -+ (module -+ (type $struct (struct (field f32) (field $y (mut f32)) (field $z f32))) -+ (table 10 anyref (struct.new_default $struct)) -+ ) -+ "unsupported initializer expression for table" -+) -diff --git a/test/core/gc/type-subtyping.wast b/test/core/gc/type-subtyping.wast -index a9022fc3..4aa36e2a 100644 ---- a/test/core/gc/type-subtyping.wast -+++ b/test/core/gc/type-subtyping.wast -@@ -740,7 +740,7 @@ - "sub type" - ) - --(assert_invalid -+(assert_invalid - (module - (type $f0 (sub (func (param i32) (result i32)))) - (type $s0 (sub $f0 (struct))) -@@ -764,7 +764,7 @@ - "sub type" +diff --git a/test/core/gc/i31.wast b/test/core/gc/i31.wast +index 6309e72b..39f35692 100644 +--- a/test/core/gc/i31.wast ++++ b/test/core/gc/i31.wast +@@ -52,12 +52,19 @@ + + (assert_trap (invoke "get_u-null") "null i31 reference") + (assert_trap (invoke "get_s-null") "null i31 reference") +- + (assert_return (invoke "get_globals") (i32.const 2) (i32.const 3)) +- + (invoke "set_global" (i32.const 1234)) + (assert_return (invoke "get_globals") (i32.const 2) (i32.const 1234)) + ++(;; Activate the following test once the new init expr is supported. ++ ;; ++ ;; ASSERTION FAILED: ++ ;; (init_expr->init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) ++ ;; || (init_expr->init_expr_type == INIT_EXPR_TYPE_REFNULL_CONST) ++ ;; || (init_expr->init_expr_type >= INIT_EXPR_TYPE_FUNCREF_CONST ++ ;; && init_expr->init_expr_type <= INIT_EXPR_TYPE_ARRAY_NEW_FIXED), ++ ;; at file /workspaces/wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c, line 4454 ++ ;; + (module $tables_of_i31ref + (table $table 3 10 i31ref) + (elem (table $table) (i32.const 0) i31ref (item (ref.i31 (i32.const 999))) +@@ -119,7 +126,9 @@ + (assert_return (invoke "get" (i32.const 1)) (i32.const 123)) + (assert_return (invoke "get" (i32.const 2)) (i32.const 456)) + (assert_return (invoke "get" (i32.const 3)) (i32.const 789)) ++;;) + ++(;; + (module $env + (global (export "g") i32 (i32.const 42)) ) - --(assert_invalid -+(assert_invalid - (module - (type $s0 (sub (struct))) - (type $f0 (sub $s0 (func (param i32) (result i32)))) -@@ -772,7 +772,7 @@ - "sub type" +@@ -146,6 +155,7 @@ ) --(assert_invalid -+(assert_invalid - (module - (type $a0 (sub (array i32))) - (type $f0 (sub $a0 (func (param i32) (result i32)))) + (assert_return (invoke "get") (i32.const 42)) ++ ;;) + + (module $anyref_global_of_i31ref + (global $c anyref (ref.i31 (i32.const 1234))) +@@ -165,6 +175,15 @@ + (invoke "set_global" (i32.const 0)) + (assert_return (invoke "get_globals") (i32.const 1234) (i32.const 0)) + ++(;; Activate the following test once the new init expr is supported. ++ ;; ++ ;; ASSERTION FAILED: ++ ;; (init_expr->init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) ++ ;; || (init_expr->init_expr_type == INIT_EXPR_TYPE_REFNULL_CONST) ++ ;; || (init_expr->init_expr_type >= INIT_EXPR_TYPE_FUNCREF_CONST ++ ;; && init_expr->init_expr_type <= INIT_EXPR_TYPE_ARRAY_NEW_FIXED), ++ ;; at file /workspaces/wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c, line 4454 ++ ;; + (module $anyref_table_of_i31ref + (table $table 3 10 anyref) + (elem (table $table) (i32.const 0) i31ref (item (ref.i31 (i32.const 999))) +@@ -226,3 +245,5 @@ + (assert_return (invoke "get" (i32.const 1)) (i32.const 123)) + (assert_return (invoke "get" (i32.const 2)) (i32.const 456)) + (assert_return (invoke "get" (i32.const 3)) (i32.const 789)) ++ ;; ++ ;;) diff --git a/test/core/global.wast b/test/core/global.wast -index 8c47fde2..1a8cc7e3 100644 +index 8c47fde2..8d3d8228 100644 --- a/test/core/global.wast +++ b/test/core/global.wast -@@ -644,7 +644,7 @@ +@@ -644,7 +644,10 @@ ) ) -(assert_return (invoke "get-elem" (i32.const 0)) (ref.null)) ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +(assert_return (invoke "get-elem" (i32.const 0)) (ref.null func)) (assert_return (invoke "get-elem" (i32.const 4)) (ref.func)) (assert_return (invoke "get-elem" (i32.const 8)) (ref.func)) -@@ -652,7 +652,7 @@ - (assert_return (invoke "get-data" (i32.const 8)) (i32.const 0x88888888)) - - (assert_invalid -- (module -+ (module - (global $g1 i32 (global.get $g2)) - (global $g2 i32 (i32.const 0)) - ) -diff --git a/test/core/imports.wast b/test/core/imports.wast -index 69f76a0b..a3844c65 100644 ---- a/test/core/imports.wast -+++ b/test/core/imports.wast -@@ -572,6 +572,7 @@ - (assert_return (invoke "grow" (i32.const 1)) (i32.const -1)) - (assert_return (invoke "grow" (i32.const 0)) (i32.const 2)) - -+(; unsupported by multi-module currently - (module $Mgm - (memory (export "memory") 1) ;; initial size is 1 - (func (export "grow") (result i32) (memory.grow (i32.const 1))) -@@ -591,6 +592,7 @@ - (func (export "size") (result i32) (memory.size)) - ) - (assert_return (invoke $Mgim2 "size") (i32.const 3)) -+;) - - - ;; Syntax errors -diff --git a/test/core/linking.wast b/test/core/linking.wast -index 6a8ba1d0..a45534fd 100644 ---- a/test/core/linking.wast -+++ b/test/core/linking.wast -@@ -64,6 +64,7 @@ - (export "Mg.set_mut" (func $set_mut)) - ) - -+(; - (assert_return (get $Mg "glob") (i32.const 42)) - (assert_return (get $Ng "Mg.glob") (i32.const 42)) - (assert_return (get $Ng "glob") (i32.const 43)) -@@ -81,6 +82,7 @@ - (assert_return (get $Ng "Mg.mut_glob") (i32.const 241)) - (assert_return (invoke $Mg "get_mut") (i32.const 241)) - (assert_return (invoke $Ng "Mg.get_mut") (i32.const 241)) -+;) - - - (assert_unlinkable -@@ -300,6 +302,7 @@ - ) - ) - -+(; - (assert_return (invoke $Mt "call" (i32.const 2)) (i32.const 4)) - (assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const 4)) - (assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5)) -@@ -322,6 +325,7 @@ - - (assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4)) - (assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call type mismatch") -+;) - - (module $Ot - (type (func (result i32))) -@@ -336,6 +340,7 @@ - ) - ) - -+(; - (assert_return (invoke $Mt "call" (i32.const 3)) (i32.const 4)) - (assert_return (invoke $Nt "Mt.call" (i32.const 3)) (i32.const 4)) - (assert_return (invoke $Nt "call Mt.call" (i32.const 3)) (i32.const 4)) -@@ -360,6 +365,7 @@ - (assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized element") - - (assert_trap (invoke $Ot "call" (i32.const 20)) "undefined element") -+;) - - (module - (table (import "Mt" "tab") 0 funcref) -@@ -398,6 +404,7 @@ - - ;; Unlike in the v1 spec, active element segments stored before an - ;; out-of-bounds access persist after the instantiation failure. -+(; - (assert_trap - (module - (table (import "Mt" "tab") 10 funcref) -@@ -409,7 +416,9 @@ - ) - (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0)) - (assert_trap (invoke $Mt "call" (i32.const 8)) "uninitialized element") -+;) - -+(; - (assert_trap - (module - (table (import "Mt" "tab") 10 funcref) -@@ -421,6 +430,7 @@ - "out of bounds memory access" - ) - (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0)) -+;) - - - (module $Mtable_ex -@@ -503,10 +513,12 @@ - ) - ) - -+(; - (assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 0xa7)) - (assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 0xa7)) - (assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2)) - (assert_return (invoke $Om "load" (i32.const 12)) (i32.const 0xa7)) -+;) - - (module - (memory (import "Mm" "mem") 0) -@@ -529,6 +541,7 @@ - ) - ) - -+(; - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 1)) - (assert_return (invoke $Pm "grow" (i32.const 2)) (i32.const 1)) - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 3)) -@@ -537,6 +550,7 @@ - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5)) - (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1)) - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5)) -+;) - - (assert_unlinkable - (module -@@ -560,8 +574,10 @@ - ) - "out of bounds memory access" - ) -+(; - (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97)) - (assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0)) -+;) - - (assert_trap - (module -@@ -573,7 +589,9 @@ - ) - "out of bounds table access" - ) -+(; - (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97)) -+;) - - ;; Store is modified if the start function traps. - (module $Ms -@@ -589,6 +607,7 @@ - ) - (register "Ms" $Ms) - -+(; - (assert_trap - (module - (import "Ms" "memory" (memory 1)) -@@ -608,3 +627,4 @@ - - (assert_return (invoke $Ms "get memory[0]") (i32.const 104)) ;; 'h' - (assert_return (invoke $Ms "get table[0]") (i32.const 0xdead)) -+;) diff --git a/test/core/ref_func.wast b/test/core/ref_func.wast -index adb5cb78..590f6262 100644 +index adb5cb78..a4f8de5a 100644 --- a/test/core/ref_func.wast +++ b/test/core/ref_func.wast @@ -4,7 +4,8 @@ @@ -419,71 +334,85 @@ index adb5cb78..590f6262 100644 (module - (func $f (import "M" "f") (param i32) (result i32)) -+ (; aot mode does not support module linking ;) ++ (;Revert to the previous once the GC feature is operational with the multi-module feature.;) + (func $f (param $x i32) (result i32) (local.get $x)) (func $g (param $x i32) (result i32) (i32.add (local.get $x) (i32.const 1)) ) diff --git a/test/core/ref_null.wast b/test/core/ref_null.wast -index 1ffd03f8..bdf7471f 100644 +index 1ffd03f8..2961ffcd 100644 --- a/test/core/ref_null.wast +++ b/test/core/ref_null.wast -@@ -11,7 +11,7 @@ +@@ -11,7 +11,10 @@ (assert_return (invoke "anyref") (ref.null any)) (assert_return (invoke "funcref") (ref.null func)) -(assert_return (invoke "ref") (ref.null)) -+(assert_return (invoke "ref") (ref.null func)) ;; we alwasy require type information ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) ++(assert_return (invoke "ref") (ref.null func)) (module -@@ -41,23 +41,23 @@ +@@ -40,24 +43,33 @@ + (global (ref null $t) (ref.null nofunc)) ) ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) ++(assert_return (invoke "anyref") (ref.null any)) ++(assert_return (invoke "anyref") (ref.null any)) (assert_return (invoke "anyref") (ref.null any)) -(assert_return (invoke "anyref") (ref.null none)) -(assert_return (invoke "anyref") (ref.null)) -+;; (assert_return (invoke "anyref") (ref.null none)) -+;; (assert_return (invoke "anyref") (ref.null func)) ++ ++(assert_return (invoke "nullref") (ref.null any)) ++(assert_return (invoke "nullref") (ref.null any)) (assert_return (invoke "nullref") (ref.null any)) -(assert_return (invoke "nullref") (ref.null none)) -(assert_return (invoke "nullref") (ref.null)) -+;; (assert_return (invoke "nullref") (ref.null none)) -+;; (assert_return (invoke "nullref") (ref.null func)) ++ ++(assert_return (invoke "funcref") (ref.null func)) ++(assert_return (invoke "funcref") (ref.null func)) (assert_return (invoke "funcref") (ref.null func)) -(assert_return (invoke "funcref") (ref.null nofunc)) -(assert_return (invoke "funcref") (ref.null)) -+;; (assert_return (invoke "funcref") (ref.null nofunc)) -+(assert_return (invoke "funcref") (ref.null func)) ++ +(assert_return (invoke "nullfuncref") (ref.null func)) -+;; (assert_return (invoke "nullfuncref") (ref.null nofunc)) (assert_return (invoke "nullfuncref") (ref.null func)) -(assert_return (invoke "nullfuncref") (ref.null nofunc)) -(assert_return (invoke "nullfuncref") (ref.null)) ++(assert_return (invoke "nullfuncref") (ref.null func)) ++ ++(assert_return (invoke "externref") (ref.null extern)) (assert_return (invoke "externref") (ref.null extern)) -(assert_return (invoke "externref") (ref.null noextern)) -(assert_return (invoke "externref") (ref.null)) -+;; (assert_return (invoke "externref") (ref.null noextern)) -+;; (assert_return (invoke "externref") (ref.null func)) ++(assert_return (invoke "externref") (ref.null extern)) ++ (assert_return (invoke "nullexternref") (ref.null extern)) -(assert_return (invoke "nullexternref") (ref.null noextern)) -(assert_return (invoke "nullexternref") (ref.null)) -+;; (assert_return (invoke "nullexternref") (ref.null noextern)) -+;; (assert_return (invoke "nullexternref") (ref.null func)) ++(assert_return (invoke "nullexternref") (ref.null extern)) ++(assert_return (invoke "nullexternref") (ref.null extern)) ++ ++(assert_return (invoke "ref") (ref.null func)) +(assert_return (invoke "ref") (ref.null func)) -+;; (assert_return (invoke "ref") (ref.null nofunc)) (assert_return (invoke "ref") (ref.null func)) -(assert_return (invoke "ref") (ref.null nofunc)) -(assert_return (invoke "ref") (ref.null)) diff --git a/test/core/return_call.wast b/test/core/return_call.wast -index 2f91f4de..ad66acca 100644 +index b9e8f8f0..8a3d7512 100644 --- a/test/core/return_call.wast +++ b/test/core/return_call.wast -@@ -102,20 +102,20 @@ +@@ -102,20 +102,23 @@ (assert_return (invoke "count" (i64.const 0)) (i64.const 0)) (assert_return (invoke "count" (i64.const 1000)) (i64.const 0)) -(assert_return (invoke "count" (i64.const 1_000_000)) (i64.const 0)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) +(assert_return (invoke "count" (i64.const 100_000)) (i64.const 0)) (assert_return (invoke "even" (i64.const 0)) (i32.const 44)) @@ -492,6 +421,7 @@ index 2f91f4de..ad66acca 100644 (assert_return (invoke "even" (i64.const 77)) (i32.const 99)) -(assert_return (invoke "even" (i64.const 1_000_000)) (i32.const 44)) -(assert_return (invoke "even" (i64.const 1_000_001)) (i32.const 99)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) +(assert_return (invoke "even" (i64.const 100_000)) (i32.const 44)) +(assert_return (invoke "even" (i64.const 100_001)) (i32.const 99)) (assert_return (invoke "odd" (i64.const 0)) (i32.const 99)) @@ -500,36 +430,39 @@ index 2f91f4de..ad66acca 100644 (assert_return (invoke "odd" (i64.const 77)) (i32.const 44)) -(assert_return (invoke "odd" (i64.const 1_000_000)) (i32.const 99)) -(assert_return (invoke "odd" (i64.const 999_999)) (i32.const 44)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) +(assert_return (invoke "odd" (i64.const 100_000)) (i32.const 99)) -+(assert_return (invoke "odd" (i64.const 99_999)) (i32.const 44)) ++(assert_return (invoke "odd" (i64.const 99_999)) (i32.const 44)) ;; Invalid typing diff --git a/test/core/return_call_indirect.wast b/test/core/return_call_indirect.wast -index acf0a72e..6b95c24b 100644 +index aa158be2..7f68b4a5 100644 --- a/test/core/return_call_indirect.wast +++ b/test/core/return_call_indirect.wast -@@ -263,8 +263,8 @@ +@@ -263,8 +263,9 @@ (assert_return (invoke "odd" (i32.const 1)) (i32.const 44)) (assert_return (invoke "odd" (i32.const 200)) (i32.const 99)) (assert_return (invoke "odd" (i32.const 77)) (i32.const 44)) -(assert_return (invoke "odd" (i32.const 200_002)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 300_003)) (i32.const 44)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) +(assert_return (invoke "odd" (i32.const 100_002)) (i32.const 99)) +(assert_return (invoke "odd" (i32.const 100_003)) (i32.const 44)) ;; Invalid syntax diff --git a/test/core/return_call_ref.wast b/test/core/return_call_ref.wast -index 353811f0..f79975b4 100644 +index 5f5a7cba..574d34a3 100644 --- a/test/core/return_call_ref.wast +++ b/test/core/return_call_ref.wast -@@ -192,20 +192,20 @@ +@@ -192,20 +192,23 @@ (assert_return (invoke "count" (i64.const 0)) (i64.const 0)) (assert_return (invoke "count" (i64.const 1000)) (i64.const 0)) -(assert_return (invoke "count" (i64.const 1_000_000)) (i64.const 0)) -+(assert_return (invoke "count" (i64.const 1200)) (i64.const 0)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) ++(assert_return (invoke "count" (i64.const 1_200)) (i64.const 0)) (assert_return (invoke "even" (i64.const 0)) (i64.const 44)) (assert_return (invoke "even" (i64.const 1)) (i64.const 99)) @@ -537,53 +470,62 @@ index 353811f0..f79975b4 100644 (assert_return (invoke "even" (i64.const 77)) (i64.const 99)) -(assert_return (invoke "even" (i64.const 1_000_000)) (i64.const 44)) -(assert_return (invoke "even" (i64.const 1_000_001)) (i64.const 99)) -+(assert_return (invoke "even" (i64.const 1200)) (i64.const 44)) -+(assert_return (invoke "even" (i64.const 1201)) (i64.const 99)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) ++(assert_return (invoke "even" (i64.const 1_200)) (i64.const 44)) ++(assert_return (invoke "even" (i64.const 1_201)) (i64.const 99)) (assert_return (invoke "odd" (i64.const 0)) (i64.const 99)) (assert_return (invoke "odd" (i64.const 1)) (i64.const 44)) (assert_return (invoke "odd" (i64.const 200)) (i64.const 99)) (assert_return (invoke "odd" (i64.const 77)) (i64.const 44)) -(assert_return (invoke "odd" (i64.const 1_000_000)) (i64.const 99)) -(assert_return (invoke "odd" (i64.const 999_999)) (i64.const 44)) -+(assert_return (invoke "odd" (i64.const 1200)) (i64.const 99)) -+(assert_return (invoke "odd" (i64.const 1119)) (i64.const 44)) ++(;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) ++(assert_return (invoke "odd" (i64.const 1_200)) (i64.const 99)) ++(assert_return (invoke "odd" (i64.const 1_199)) (i64.const 44)) ;; More typing diff --git a/test/core/select.wast b/test/core/select.wast -index 61e4dc22..b0b1344c 100644 +index 61e4dc22..f7f92f81 100644 --- a/test/core/select.wast +++ b/test/core/select.wast -@@ -277,7 +277,7 @@ +@@ -277,7 +277,10 @@ (assert_return (invoke "select-f64-t" (f64.const 2) (f64.const nan:0x20304) (i32.const 0)) (f64.const nan:0x20304)) (assert_return (invoke "join-funcnull" (i32.const 1)) (ref.func)) -(assert_return (invoke "join-funcnull" (i32.const 0)) (ref.null)) -+(assert_return (invoke "join-funcnull" (i32.const 0)) (ref.null func)) ;; we require type in expected results ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) ++(assert_return (invoke "join-funcnull" (i32.const 0)) (ref.null func)) (assert_trap (invoke "select-trap-left" (i32.const 1)) "unreachable") (assert_trap (invoke "select-trap-left" (i32.const 0)) "unreachable") diff --git a/test/core/table.wast b/test/core/table.wast -index a11dce56..ace19ac8 100644 +index a11dce56..d9820382 100644 --- a/test/core/table.wast +++ b/test/core/table.wast -@@ -103,11 +103,11 @@ +@@ -103,11 +103,15 @@ (func (export "get5") (result funcref) (table.get $t5 (i32.const 9))) ) -(assert_return (invoke "get1") (ref.null)) ++(; Switch back to the original configuration once the scripts perform ++ ; typing comparison rather than comparing strings ++ ;) +(assert_return (invoke "get1") (ref.null func)) (assert_return (invoke "get2") (ref.func)) (assert_return (invoke "get3") (ref.func)) -(assert_return (invoke "get4") (ref.func)) -(assert_return (invoke "get5") (ref.func)) -+(assert_return (invoke "get4") (ref.null func)) ;; We don't give a value to the imported global -+(assert_return (invoke "get5") (ref.null func)) ;; So these two tables are initialized as ref.null ++(;Revert to previous ones once the capability to import global is aligned;) ++(assert_return (invoke "get4") (ref.null func)) ++(assert_return (invoke "get5") (ref.null func)) (assert_invalid diff --git a/test/core/table_copy.wast b/test/core/table_copy.wast -index 380e84ee..f37e745c 100644 +index 380e84ee..288cc985 100644 --- a/test/core/table_copy.wast +++ b/test/core/table_copy.wast @@ -14,11 +14,12 @@ @@ -595,16 +537,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -106,11 +107,11 @@ +@@ -106,11 +107,12 @@ (module (type (func (result i32))) ;; type #0 @@ -613,15 +555,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 + (func (export "ef1") (result i32) (i32.const 1)) + (func (export "ef2") (result i32) (i32.const 2)) + (func (export "ef3") (result i32) (i32.const 3)) -+ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -198,11 +199,11 @@ +@@ -198,11 +200,12 @@ (module (type (func (result i32))) ;; type #0 @@ -630,15 +573,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -290,11 +291,11 @@ +@@ -290,11 +293,12 @@ (module (type (func (result i32))) ;; type #0 @@ -647,15 +591,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -382,11 +383,11 @@ +@@ -382,11 +386,12 @@ (module (type (func (result i32))) ;; type #0 @@ -664,15 +609,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -474,11 +475,11 @@ +@@ -474,11 +479,12 @@ (module (type (func (result i32))) ;; type #0 @@ -681,15 +627,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -566,11 +567,11 @@ +@@ -566,11 +572,12 @@ (module (type (func (result i32))) ;; type #0 @@ -698,15 +645,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -658,11 +659,11 @@ +@@ -658,11 +665,12 @@ (module (type (func (result i32))) ;; type #0 @@ -715,15 +663,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -750,11 +751,11 @@ +@@ -750,11 +758,12 @@ (module (type (func (result i32))) ;; type #0 @@ -732,15 +681,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -842,11 +843,11 @@ +@@ -842,11 +851,12 @@ (module (type (func (result i32))) ;; type #0 @@ -749,15 +699,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -934,11 +935,11 @@ +@@ -934,11 +944,12 @@ (module (type (func (result i32))) ;; type #0 @@ -766,15 +717,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1026,11 +1027,11 @@ +@@ -1026,11 +1037,12 @@ (module (type (func (result i32))) ;; type #0 @@ -783,15 +735,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1118,11 +1119,11 @@ +@@ -1118,11 +1130,12 @@ (module (type (func (result i32))) ;; type #0 @@ -800,15 +753,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1210,11 +1211,11 @@ +@@ -1210,11 +1223,12 @@ (module (type (func (result i32))) ;; type #0 @@ -817,15 +771,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1302,11 +1303,11 @@ +@@ -1302,11 +1316,12 @@ (module (type (func (result i32))) ;; type #0 @@ -834,15 +789,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1394,11 +1395,11 @@ +@@ -1394,11 +1409,12 @@ (module (type (func (result i32))) ;; type #0 @@ -851,15 +807,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1486,11 +1487,11 @@ +@@ -1486,11 +1502,12 @@ (module (type (func (result i32))) ;; type #0 @@ -868,15 +825,16 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1578,11 +1579,11 @@ +@@ -1578,11 +1595,12 @@ (module (type (func (result i32))) ;; type #0 @@ -885,16 +843,17 @@ index 380e84ee..f37e745c 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) diff --git a/test/core/table_init.wast b/test/core/table_init.wast -index 0b2d26f7..bdab6a01 100644 +index 0b2d26f7..65b92bf8 100644 --- a/test/core/table_init.wast +++ b/test/core/table_init.wast @@ -14,11 +14,12 @@ @@ -906,12 +865,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) @@ -924,12 +883,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) @@ -942,12 +901,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t0) (i32.const 2) func 3 1 4 1) @@ -960,12 +919,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) @@ -978,12 +937,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) @@ -996,12 +955,12 @@ index 0b2d26f7..bdab6a01 100644 - (import "a" "ef2" (func (result i32))) - (import "a" "ef3" (func (result i32))) - (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 ++ (;Revert to previous ones once the capability to import table is enabled;) ++ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 ++ (func (export "ef1") (result i32) (i32.const 1)) ++ (func (export "ef2") (result i32) (i32.const 2)) ++ (func (export "ef3") (result i32) (i32.const 3)) ++ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 (table $t0 30 30 funcref) (table $t1 30 30 funcref) (elem (table $t1) (i32.const 2) func 3 1 4 1) diff --git a/tests/wamr-test-suites/spec-test-script/gc_nuttx_tail_call.patch b/tests/wamr-test-suites/spec-test-script/gc_nuttx_tail_call.patch index efbd9e1780..5992950907 100644 --- a/tests/wamr-test-suites/spec-test-script/gc_nuttx_tail_call.patch +++ b/tests/wamr-test-suites/spec-test-script/gc_nuttx_tail_call.patch @@ -1,53 +1,56 @@ diff --git a/test/core/return_call.wast b/test/core/return_call.wast -index ad66acca..b27af19b 100644 +index 8a3d7512..5a4eba68 100644 --- a/test/core/return_call.wast +++ b/test/core/return_call.wast -@@ -102,20 +102,20 @@ - +@@ -103,22 +103,22 @@ (assert_return (invoke "count" (i64.const 0)) (i64.const 0)) (assert_return (invoke "count" (i64.const 1000)) (i64.const 0)) + (;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) -(assert_return (invoke "count" (i64.const 100_000)) (i64.const 0)) -+(assert_return (invoke "count" (i64.const 1001)) (i64.const 0)) ++(assert_return (invoke "count" (i64.const 1_001)) (i64.const 0)) (assert_return (invoke "even" (i64.const 0)) (i32.const 44)) (assert_return (invoke "even" (i64.const 1)) (i32.const 99)) (assert_return (invoke "even" (i64.const 100)) (i32.const 44)) (assert_return (invoke "even" (i64.const 77)) (i32.const 99)) + (;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) -(assert_return (invoke "even" (i64.const 100_000)) (i32.const 44)) -(assert_return (invoke "even" (i64.const 100_001)) (i32.const 99)) -+(assert_return (invoke "even" (i64.const 1000)) (i32.const 44)) -+(assert_return (invoke "even" (i64.const 1001)) (i32.const 99)) ++(assert_return (invoke "even" (i64.const 1_000)) (i32.const 44)) ++(assert_return (invoke "even" (i64.const 1_001)) (i32.const 99)) (assert_return (invoke "odd" (i64.const 0)) (i32.const 99)) (assert_return (invoke "odd" (i64.const 1)) (i32.const 44)) (assert_return (invoke "odd" (i64.const 200)) (i32.const 99)) (assert_return (invoke "odd" (i64.const 77)) (i32.const 44)) + (;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) -(assert_return (invoke "odd" (i64.const 100_000)) (i32.const 99)) --(assert_return (invoke "odd" (i64.const 99_999)) (i32.const 44)) -+(assert_return (invoke "odd" (i64.const 1000)) (i32.const 99)) -+(assert_return (invoke "odd" (i64.const 999)) (i32.const 44)) +-(assert_return (invoke "odd" (i64.const 99_999)) (i32.const 44)) ++(assert_return (invoke "odd" (i64.const 1_000)) (i32.const 99)) ++(assert_return (invoke "odd" (i64.const 999)) (i32.const 44)) ;; Invalid typing diff --git a/test/core/return_call_indirect.wast b/test/core/return_call_indirect.wast -index 6b95c24b..a9e86d42 100644 +index 7f68b4a5..08a31417 100644 --- a/test/core/return_call_indirect.wast +++ b/test/core/return_call_indirect.wast -@@ -257,14 +257,14 @@ +@@ -257,15 +257,15 @@ (assert_return (invoke "even" (i32.const 1)) (i32.const 99)) (assert_return (invoke "even" (i32.const 100)) (i32.const 44)) (assert_return (invoke "even" (i32.const 77)) (i32.const 99)) -(assert_return (invoke "even" (i32.const 100_000)) (i32.const 44)) -(assert_return (invoke "even" (i32.const 111_111)) (i32.const 99)) -+(assert_return (invoke "even" (i32.const 1000)) (i32.const 44)) -+(assert_return (invoke "even" (i32.const 1111)) (i32.const 99)) ++(assert_return (invoke "even" (i32.const 1_000)) (i32.const 44)) ++(assert_return (invoke "even" (i32.const 1_001)) (i32.const 99)) (assert_return (invoke "odd" (i32.const 0)) (i32.const 99)) (assert_return (invoke "odd" (i32.const 1)) (i32.const 44)) (assert_return (invoke "odd" (i32.const 200)) (i32.const 99)) (assert_return (invoke "odd" (i32.const 77)) (i32.const 44)) + (;Return to the original configuration after we have corrected the error in the AOT/JIT tail-call implementation.;) -(assert_return (invoke "odd" (i32.const 100_002)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 100_003)) (i32.const 44)) -+(assert_return (invoke "odd" (i32.const 1002)) (i32.const 99)) -+(assert_return (invoke "odd" (i32.const 1003)) (i32.const 44)) ++(assert_return (invoke "odd" (i32.const 1_002)) (i32.const 99)) ++(assert_return (invoke "odd" (i32.const 1_003)) (i32.const 44)) ;; Invalid syntax diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 64abd9f35f..31f8b3746b 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -467,8 +467,8 @@ function spec_test() git clone -b main --single-branch https://github.com/WebAssembly/gc.git spec pushd spec - # Reset to commit: "[test] Unify the error message." - git reset --hard 0caaadc65b5e1910512d8ae228502edcf9d60390 + # Dec 9, 2024. Merge branch 'funcref' + git reset --hard 756060f5816c7e2159f4817fbdee76cf52f9c923 git apply ../../spec-test-script/gc_ignore_cases.patch || exit 1 if [[ ${ENABLE_QEMU} == 1 ]]; then @@ -477,6 +477,13 @@ function spec_test() git apply ../../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. + # + # $ $ /opt/wabt-1.0.36/bin/wast2json --enable-all ../spec/test/core/br_if.wast + # + # ../spec/test/core/br_if.wast:670:26: error: unexpected token "null", expected a numeric index or a name (e.g. 12 or $foo). + # (func $f (param (ref null $t)) (result funcref) (local.get 0)) + # compile_reference_interpreter elif [[ ${ENABLE_MEMORY64} == 1 ]]; then echo "checkout spec for memory64 proposal" From b6dea221a609606ce6c3dcaa0f4d0399ea5bc4dc Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:08:09 +0800 Subject: [PATCH 070/431] Fix wasm loader check data segment count (#4039) correctly report error when datacount section has non-zero data segment count while the data section is not present --- core/iwasm/interpreter/wasm_loader.c | 29 ++++++++++++++++++++--- core/iwasm/interpreter/wasm_mini_loader.c | 5 ++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index d495ba63ef..559d1c33ee 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -4713,6 +4713,21 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end, return false; } +#if WASM_ENABLE_BULK_MEMORY != 0 +static bool +check_data_count_consistency(bool has_datacount_section, int datacount_len, + int data_seg_len, char *error_buf, + uint32 error_buf_size) +{ + if (has_datacount_section && datacount_len != data_seg_len) { + set_error_buf(error_buf, error_buf_size, + "data count and data section have inconsistent lengths"); + return false; + } + return true; +} +#endif + static bool load_data_segment_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, @@ -4736,9 +4751,9 @@ load_data_segment_section(const uint8 *buf, const uint8 *buf_end, read_leb_uint32(p, p_end, data_seg_count); #if WASM_ENABLE_BULK_MEMORY != 0 - if (has_datacount_section && data_seg_count != module->data_seg_count1) { - set_error_buf(error_buf, error_buf_size, - "data count and data section have inconsistent lengths"); + if (!check_data_count_consistency(has_datacount_section, + module->data_seg_count1, data_seg_count, + error_buf, error_buf_size)) { return false; } #endif @@ -5926,6 +5941,14 @@ load_from_sections(WASMModule *module, WASMSection *sections, section = section->next; } +#if WASM_ENABLE_BULK_MEMORY != 0 + if (!check_data_count_consistency( + has_datacount_section, module->data_seg_count1, + module->data_seg_count, error_buf, error_buf_size)) { + return false; + } +#endif + module->aux_data_end_global_index = (uint32)-1; module->aux_heap_base_global_index = (uint32)-1; module->aux_stack_top_global_index = (uint32)-1; diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 1638459a53..d20c28d7d0 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2734,6 +2734,11 @@ load_from_sections(WASMModule *module, WASMSection *sections, section = section->next; } +#if WASM_ENABLE_BULK_MEMORY != 0 + bh_assert(!has_datacount_section + || module->data_seg_count == module->data_seg_count1); +#endif + module->aux_data_end_global_index = (uint32)-1; module->aux_heap_base_global_index = (uint32)-1; module->aux_stack_top_global_index = (uint32)-1; From d0c6da10ff45953565709005125a8649e1ab34da Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:28:30 +0000 Subject: [PATCH 071/431] 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 87f0775ecc..2d5f6fde7f 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 072/431] clang-format --- core/iwasm/aot/aot_runtime.c | 40 +++++++++++--------- core/iwasm/aot/aot_runtime.h | 5 ++- core/iwasm/common/wasm_runtime_common.c | 39 ++++++++++--------- 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, 94 insertions(+), 75 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 2d5f6fde7f..134cd98589 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 5405772c90..7a26be3ea9 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 b631a9e114..acf6f55446 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); - - #if WASM_ENABLE_INTERP != 0 + /* + * 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 +#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 6157c64317..1650615efc 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 cf75eeb6cc..ca6020c3a8 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 529e0a2fcb..90fed59ba3 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 7322bb16c3..d67461e91f 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 073/431] 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 ca6020c3a8..68e3d509a9 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 074/431] 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 acf6f55446..9aa4101ef7 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 68e3d509a9..430555ca8f 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 075/431] 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 430555ca8f..aba7fd4ec6 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 076/431] support standard frames as well --- core/iwasm/aot/aot_runtime.c | 89 ++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 134cd98589..e137e59ca5 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; - - bool is_top_index_in_range = - top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); +/* + * 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)); 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 077/431] format --- core/iwasm/aot/aot_runtime.c | 114 ++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index e137e59ca5..408d6b5c8e 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; - - bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); + /* + * 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)); 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 078/431] 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 a4e31766d2..1416405460 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 2d4eb82d99..834311f7ea 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 f61b24f7cd..f44644e456 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 90fed59ba3..4ac882bffb 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 079/431] 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 4ac882bffb..6ab5d756b1 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 080/431] 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 408d6b5c8e..df956549a7 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 081/431] 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 6ab5d756b1..e0f55353dc 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 d67461e91f..1b439bac16 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 082/431] 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 df956549a7..ee483fa5b2 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 083/431] 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 ee483fa5b2..028bfe89f6 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 5dcffaa7d2685e9bf31015fc68fc75cd049399c5 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Sat, 1 Feb 2025 12:14:06 +0800 Subject: [PATCH 084/431] Update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in CI (#4050) - update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in ci --- .github/workflows/compilation_on_android_ubuntu.yml | 2 +- doc/build_wasm_app.md | 10 +++++----- samples/debug-tools/CMakeLists.txt | 2 +- .../wamr-ide/VSCode-Extension/resource/test/build.sh | 2 +- .../wamr-ide/VSCode-Extension/src/test/suite/utils.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 119c8b2d05..b08498cc0e 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -817,7 +817,7 @@ jobs: - name: install dependencies run: | - rustup target add wasm32-wasi + rustup target add wasm32-wasip1 sudo apt update && sudo apt-get install -y lld ninja-build npm install working-directory: test-tools/wamr-ide/VSCode-Extension diff --git a/doc/build_wasm_app.md b/doc/build_wasm_app.md index 9536d1a8d1..95d237346c 100644 --- a/doc/build_wasm_app.md +++ b/doc/build_wasm_app.md @@ -16,24 +16,24 @@ For [AssemblyScript](https://github.com/AssemblyScript/assemblyscript), please r For Rust, please refer to [Install Rust and Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) to install *cargo*, *rustc* and *rustup*. By default they are under ~/.cargo/bin. -And then run such a command to install `wasm32-wasi` target. +And then run such a command to install `wasm32-wasip1` target. ``` bash -$ rustup target add wasm32-wasi +$ rustup target add wasm32-wasip1 ``` To build WASM applications, run ``` bash -$ cargo build --target wasm32-wasi +$ cargo build --target wasm32-wasip1 ``` -The output files are under `target/wasm32-wasi`. +The output files are under `target/wasm32-wasip1`. To build a release version ``` bash -$ cargo build --release --target wasm32-wasi +$ cargo build --release --target wasm32-wasip1 ``` diff --git a/samples/debug-tools/CMakeLists.txt b/samples/debug-tools/CMakeLists.txt index ce06029a56..411106bb30 100644 --- a/samples/debug-tools/CMakeLists.txt +++ b/samples/debug-tools/CMakeLists.txt @@ -72,7 +72,7 @@ add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) include(ExternalProject) # wasm32-wasi -ExternalProject_Add(wasm33-wasi +ExternalProject_Add(wasm32-wasi 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} diff --git a/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh b/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh index e175c91066..33ae79d442 100755 --- a/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh +++ b/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh @@ -1,2 +1,2 @@ # compile with debug symbols and no optimization -rustc --target wasm32-wasi ./test.rs -g -C opt-level=0 \ No newline at end of file +rustc --target wasm32-wasip1 ./test.rs -g -C opt-level=0 \ No newline at end of file diff --git a/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts b/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts index 3f40596c3d..69c474b258 100644 --- a/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts +++ b/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts @@ -39,7 +39,7 @@ export function setBpAtMarker(file: string, bpMarker: string): void { export function compileRustToWasm(): void { const testResourceFolder = `${EXTENSION_PATH}/resource/test`; // compile with debug symbols and no optimization - const cmd = `rustc --target wasm32-wasi ${testResourceFolder}/test.rs -g -C opt-level=0 -o ${testResourceFolder}/test.wasm`; + const cmd = `rustc --target wasm32-wasip1 ${testResourceFolder}/test.rs -g -C opt-level=0 -o ${testResourceFolder}/test.wasm`; try { cp.execSync(cmd, { stdio: [null, null, process.stderr] }); From 6f0e0e5f0687489c6db0d2a16950ba6fdba52d59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:37:29 +0000 Subject: [PATCH 085/431] build(deps): Bump github/codeql-action from 3.28.1 to 3.28.5 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.1 to 3.28.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.1...v3.28.5) --- 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 753322fcc1..431969a3cb 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.1 + uses: github/codeql-action/init@v3.28.5 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.1 + uses: github/codeql-action/analyze@v3.28.5 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.1 + uses: github/codeql-action/upload-sarif@v3.28.5 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 39f2f98351..5c1b0448d3 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@db7177a1c66bea89f5e7ce32d0ea48bea4a0d460 # v2.2.4 + uses: github/codeql-action/upload-sarif@e7c0c9d71b7bd108fd12e06b56fc58d3d154164d # v2.2.4 with: sarif_file: results.sarif From 7f1e6125a25fa14a3ae18b6a1b28735bfebcce5a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:29:13 +0000 Subject: [PATCH 086/431] build(deps): Bump github/codeql-action from 3.28.5 to 3.28.8 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.5 to 3.28.8. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.5...v3.28.8) --- 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 431969a3cb..a98d5f1a95 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.5 + uses: github/codeql-action/init@v3.28.8 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.5 + uses: github/codeql-action/analyze@v3.28.8 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.5 + uses: github/codeql-action/upload-sarif@v3.28.8 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 5c1b0448d3..4c743d2ec8 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@e7c0c9d71b7bd108fd12e06b56fc58d3d154164d # v2.2.4 + uses: github/codeql-action/upload-sarif@0701025a8b1600e416be4f3bb5a830b1aa6af01e # v2.2.4 with: sarif_file: results.sarif From b2c7cb23758adc19f6c69f53c6ee3594f72927ca Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Wed, 5 Feb 2025 03:31:49 +0000 Subject: [PATCH 087/431] 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 b08498cc0e..11a512448f 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 fe3a8c5122..fdbe971d26 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 304b0c9774..00e126d880 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 filter_output(output: str) -> str: 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 088/431] 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 6a30bfb7b7..6173e73b5f 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 27d26f0937..fbbbf6771d 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 bde3ee034d..97360e73e7 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 22700dcdd6..b96bcd1bf4 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 @@ aot_create_perf_map(const AOTModule *module, char *error_buf, 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 0000000000..58757f767f --- /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 0000000000..dd8f0ecb5e --- /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 efff88dd07..c82501fad4 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 bc56f40308..f54a3e542a 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 089/431] 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 | 153 ++++++++++++------ doc/stability_wasm_proposals.md | 2 +- product-mini/platforms/common/wasm_proposal.c | 48 ++++++ product-mini/platforms/posix/main.c | 4 + 4 files changed, 159 insertions(+), 48 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 6173e73b5f..0e9364d4ff 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,13 +274,25 @@ 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") +if (WAMR_BUILD_THREAD_MGR EQUAL 1) + message (" Thread manager enabled") +endif () +if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) + message (" Lib pthread enabled") endif () +if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1) + message (" Lib pthread semaphore enabled") +endif () +if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1) + message (" Lib wasi-threads enabled") +endif () +if (WAMR_BUILD_LIBC_EMCC EQUAL 1) + message (" Libc emcc enabled") +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") @@ -233,24 +300,10 @@ 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) @@ -270,31 +323,11 @@ if (WAMR_BUILD_MEMORY64 EQUAL 1) 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 () -if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) - message (" Lib pthread enabled") -endif () -if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1) - message (" Lib pthread semaphore enabled") -endif () -if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1) - message (" Lib wasi-threads enabled") -endif () -if (WAMR_BUILD_LIBC_EMCC EQUAL 1) - message (" Libc emcc enabled") -endif () -if (WAMR_BUILD_LIB_RATS EQUAL 1) - message (" Lib rats enabled") -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 98617d15b1..715f2f3bdf 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 0000000000..4bf6ab3e95 --- /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 af50223a4f..fa5dcb2c34 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 090/431] 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 0f7b5d3d9a..18a098a455 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 091/431] 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 a637c3643c..6362d0e56e 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 0e9364d4ff..88abf7324f 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 0000000000..d5304bcd00 --- /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 4fe37e2d76..43ce5b96aa 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 0000000000..495b8d3b69 --- /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 321c4a955b..c3d02da6ba 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 092/431] 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 5c05259176..19bc1b11e7 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 8533ea68ce..7676ea6fb8 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 12ed8052fe..1f955a10b7 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 dd1bbc41a5..5640a384a0 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 ea5a4f4b9d..ca54aa1556 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 20b3fdfac1..927e6f4592 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 aa3de6dacb..a29dbd69c1 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 c3d02da6ba..527d18035f 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 0032832627..c32a0b9777 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 0dc5d96999..dd03cb356f 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 40e925b16a..ff438ee8c1 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 f54a3e542a..4c32fa9e61 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 093/431] 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 d5304bcd00..04c4e1ccb0 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 9fdd65d605..0000000000 --- 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 0000000000..a08040c22f --- /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 4c32fa9e61..9975dab7b3 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 094/431] 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 43ce5b96aa..0000000000 --- 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 095/431] 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 0000000000..d1becac61f --- /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 495b8d3b69..e28df65ce4 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 a08040c22f..78e034a3df 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 096/431] 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 0000000000..7d82dddc6c --- /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 11a512448f..057082ebc5 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 097/431] 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 7d82dddc6c..ab23ecf9ed 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 098/431] 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 74df84e56c..4f3d8689f2 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 099/431] [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 02ac831742..097e5348b4 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 2d5a667039..4b3d8d942d 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 100/431] 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 4f3d8689f2..d4ec6158fb 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 101/431] 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 1c50fe75f6..80e379513c 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 102/431] 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 a98d5f1a95..0c3a2ad15c 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 4c743d2ec8..f373e1b0ba 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 103/431] 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 e9fa8f9e16..af00020c97 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 f4f5a834d1..73c2c761f6 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 104/431] 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 9fc4601486..241a0eec8a 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 b7c995af88..ec9e632af0 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 105/431] 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 ec6bb39548..d44afd7ba7 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 106/431] 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 d44afd7ba7..d8bcbd26c7 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 107/431] [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 c9e6d206e1..bafa3c86c8 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 559d1c33ee..e72bf94fab 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 108/431] 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 cc6badd9e4..95cea7fe9b 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 6177d27e72..c0c7622c9d 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 4b3d8d942d..391d899cf4 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 109/431] 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 6598f7a8b6..f4f02bff63 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 110/431] 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 bdfd4fcb2c..e4b7732bc3 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 111/431] 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 9b2436a2bd..cfb27fdeb4 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 112/431] 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 | 98 ++++++++----------- 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 | 48 +++++---- 7 files changed, 164 insertions(+), 110 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 6362d0e56e..e52c86cf27 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 () - - 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) -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) -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) +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}) +if (WAMR_BUILD_WASM_CACHE EQUAL 1) + target_link_libraries(vmlib INTERFACE boringssl_crypto) +endif () + +if (MINGW) + target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32) + target_link_libraries(vmlib PRIVATE ws2_32) +endif () + +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 88abf7324f..614830094a 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 0000000000..05ec5a8cda --- /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 0000000000..4ebb1d799e --- /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 1f955a10b7..594110a442 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 (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) + +set_version_info (vmlib) -add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +target_include_directories(vmlib INTERFACE + $ +) -install (TARGETS libiwasm DESTINATION lib) +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 (libiwasm PROPERTIES OUTPUT_NAME iwasm) +set_target_properties (vmlib PROPERTIES + OUTPUT_NAME iwasm + PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}" +) -set_version_info (libiwasm) +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) -target_link_libraries (libiwasm ${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 527d18035f..be0c57edef 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 +) + +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 +) -target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) +install_iwasm_package () diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index ff438ee8c1..5fcc276a19 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}) - -if (MINGW) - target_link_libraries (iwasm ws2_32) -endif () - -add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +target_link_libraries (iwasm vmlib) -set_version_info (libiwasm) +add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) -install (TARGETS libiwasm DESTINATION lib) +target_include_directories(vmlib INTERFACE + $ +) -set_target_properties (libiwasm PROPERTIES OUTPUT_NAME 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}) +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 (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 113/431] 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 97360e73e7..0ba3de7bdd 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 114/431] 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 6362d0e56e..287559ff16 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 88abf7324f..c7cfff8423 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 f5a135be95..0cd53e4a5c 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 7a26be3ea9..0cc66c4b6a 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 7046c3b1a5..8d04f37996 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 1650615efc..19f11bd48f 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 aba7fd4ec6..18a417cc90 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 9dd68cca02..c616ac44b4 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 1b439bac16..84abf63b15 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 115/431] 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 c7cfff8423..df71198f1b 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 0cd53e4a5c..78b4b60f4b 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 0cc66c4b6a..764403f72b 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 8d04f37996..5ce16a14d1 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 19f11bd48f..44406cdb45 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 18a417cc90..a17f13f247 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 116/431] 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 d4ec6158fb..8e008f11b3 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 117/431] 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 1d972f5fa3..1b65b15d1a 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 d97883a8e4..0c5bb1c091 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 db0f38a563..994c3e4e2e 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 118/431] 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 8e008f11b3..1f942ec6c3 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 119/431] 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 1b65b15d1a..7f54c57067 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 0c5bb1c091..db350bc8f4 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 120/431] 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 7f54c57067..d5cad885ca 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 121/431] 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 a97275d242..fda17d5a7e 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 122/431] 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 0c3a2ad15c..fd44150142 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 8138a86127..eabe017889 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 f373e1b0ba..442ef7364a 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 123/431] 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 fd44150142..302b27274e 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 442ef7364a..497820c156 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 124/431] 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 497820c156..e00638ab1e 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 125/431] 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 e00638ab1e..768b0eff4f 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 126/431] 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 5ce16a14d1..a007c41f18 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 c616ac44b4..9431b0bed0 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 84abf63b15..1cdce10edf 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 127/431] 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 14ee4dd2b7..a3ac5113cf 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 128/431] 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 e72bf94fab..d00f761dff 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 129/431] 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 764403f72b..a338cb4ef6 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 a007c41f18..065bff1daa 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 44406cdb45..61b44aef65 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 a17f13f247..cacc68e2a3 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 9431b0bed0..0f75eb9f92 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 1cdce10edf..3747eb80ff 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 130/431] 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 61b44aef65..f89c8b5eec 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 131/431] 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 78b4b60f4b..19e71889dd 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 132/431] 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 fbbbf6771d..d71aaca391 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 19e71889dd..b06b19af15 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 a338cb4ef6..5be51c05a7 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 065bff1daa..99f0522e99 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 f89c8b5eec..c6425af206 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 cacc68e2a3..e63ff01245 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 0f75eb9f92..38fc022925 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 3747eb80ff..8d38c8831c 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 133/431] 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 b06b19af15..6335ec4058 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 134/431] 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 38fc022925..609ad4a3ba 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 135/431] 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 0ba3de7bdd..0817f6c782 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 136/431] 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 d5c45a4413..0019b5eee1 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 5f47cce130..76d1706dcf 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 137/431] 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 6335ec4058..85b686ef9e 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 99f0522e99..ce4d465283 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 138/431] 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 ce4d465283..d900dc233a 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 139/431] 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 609ad4a3ba..b4b55e65ac 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 140/431] 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 85b686ef9e..585a30728c 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 141/431] 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 0019b5eee1..04ec4e3831 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 cde884457b..64be528bd7 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 142/431] 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 0817f6c782..83f393c89d 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 26815334f7..e42d2cd8e8 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 143/431] 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 04ec4e3831..d5c45a4413 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 95cea7fe9b..5a2206b6e7 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 144/431] 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 585a30728c..2e267e9509 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 b4b55e65ac..400a6ae6c3 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 145/431] 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 2e267e9509..db9002bb1b 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 146/431] 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 db9002bb1b..bf7f51964f 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 400a6ae6c3..64719f7f5f 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 147/431] 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 64be528bd7..b8cfcc989d 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 148/431] 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 0e04101d29..a8ab964273 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 c57cfc57af..c3edfe5035 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 83f393c89d..9ca64f9c82 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 fca1b80da1..a866883d7c 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 ea5cbcb360..f48a429c50 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 a6ccc1508e..f940c3403e 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 78a4bab82d..19bc5d67cf 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 0908f73cc2..87039f44c1 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 218cd91e01..3f12b91d3f 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 b5928d95c1..85f3770f64 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 d5c45a4413..269ec5776f 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 48465fc940..e33fd9f3a5 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 06d8e42bdb..889e2304b5 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 cfb27fdeb4..ecb75968fc 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 9adf96ac52..e685fccd92 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 a3ac5113cf..a9fd68c244 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 77925d62d8..9db1d5bfe4 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 6a1902d1fd..ada4b5d35b 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 79c72503e7..967bf14b5e 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 @@ lower_select(JitCompContext *cc, x86::Assembler &a, COND_OP op, JitReg r0, 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 @@ lower_return(JitCompContext *cc, x86::Assembler &a, JitInsn *insn) * 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 8fe48f142b..02619a4d2f 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 9274e7217a..04140b6aeb 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 ca5521a140..566783b6f6 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 bef3fcc0c4..6b3acfa0b4 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 70ca228acf..96e5a57cfb 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 273657246d..17beb3ad74 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 98668470fb..d504e984c8 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 359a6979c7..96b9ba2b21 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 d00f761dff..31424d21e9 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, */ 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 d20c28d7d0..ecda490dfe 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 98429bbb0a..78eb457f54 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 c4c2d2857e..79baebfa43 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 d958fa39cb..580ce79871 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 ed8463866f..3972c76ed6 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 58d29163c3..23c867b0ab 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 6a3b5a47d6..f63d57e074 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 00e126d880..3637bc3714 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 e272b30147..74214b2246 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 ff65b4e7c0..9913ca2b6a 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 c902d5711b..c904942010 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 e4c79e339a..ea84d98cdb 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 8ab2df5456..893dd56383 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 1d10246068..80b7d6545e 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 37b8399b85..12843b7c14 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 4f4bbef9b8..3a46a41709 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 edf977dd6f..b1a91cf1cd 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 a9062bfece..893ed0b456 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 7102d42a14..3265ba6010 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 95d237346c..ef9bea9e24 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 5aa505ab3e..1ab5901fa6 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 129287bde7..62ed51e0b2 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 1e7a1f3cf8..5563d95793 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 2f0b351253..b0f86e5f4c 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 9f24cdaa08..fc997868bd 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 6f6ae73275..2db1fbb252 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 27ddd9fa91..edbfb62f7e 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 8c7aef30cb..d564a85a17 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 f8932bdec3..9c2b43b791 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 @@ iwasm(int argc, char **argv) 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 5f8bd41ae4..aab096b8c4 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 1374c8dd89..0d0c45ae54 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 5a8dc578fb..0dd25a99e2 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 731ba62c24..5aac0a5f45 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 be1cc6e74c..8af01b23ca 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 e4e9d87d42..5b9b35430e 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 911dfb7ab3..522cbf47b0 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 aad4494838..ec5009b13f 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 2798dc252a..2cc03e2b8d 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 c71cf4553d..2aaf0b5efd 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 810a455f86..c800764a9e 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 5889641451..2feac57203 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 9b61a6e744..44ac35fc1f 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 b232767061..22595d1559 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 0e6a3a41b4..af13d5d3e9 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 14ce063876..a8ad3cffb7 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 f42e9217bc..0dee1c8d13 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 9a07404645..bba411adef 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 6325a803ab..f9611c4bb5 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 7e832145f7..c110551c51 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 @@ } } -# 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 c30cb5af22..856105afb6 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 6fd5f16822..91c6396875 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 faf316ab3d..d96703ad11 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 261b378e46..31d8cccb44 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 8592a4b610..6fbccbb176 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 64c5533bb2..8b0f63a8ed 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 a269f51ebc..849189c907 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 8c4c93fcea..d10d639a15 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 f7e6e8ee78..70f119f9e5 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 f9dabe1c81..aa7b08df3a 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 fc4bfe2f1f..c77d16c6d1 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 dcebe04b47..de4ab17c4a 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 9bf04664ab..e1ee9e15dd 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 af00020c97..5bceccec8f 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 f4f02bff63..444120c1ac 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 dafdbb7917..198dfbc917 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 77eb53d7ea..a5db0e0335 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 67315a594c..af36f308ca 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 9d6a9379cd..e18e64fb1f 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 06c162b623..5c5b464997 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 978b540227..15a02673b2 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 30e44cea31..f7ff26ae44 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 faa7a807b9..bd0861dcf9 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 1d1cb528d7..7f7d574c38 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 4b651ef177..496170226f 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 981c52f253..de8b83505d 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 250fb79268..cb76b89e0c 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 c540d8f36c..e808aea31e 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 3da9fba5d7..fae7c8c481 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 82bedf32fa..41fe9f9274 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 73c2c761f6..670fa599bf 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 149/431] 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 050de6dfa4..9070dd5219 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 150/431] 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 302b27274e..dae8190f11 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 768b0eff4f..2a378c8790 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 151/431] 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 c6deab6fca..b771b1c402 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 152/431] 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 4bf6ab3e95..12bbf79bc1 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 153/431] 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 | 1953 +++++++++++++++-- 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, 2337 insertions(+), 221 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 057082ebc5..83cd154afe 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 70597c366a..b865a59fe2 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 312944be59..2c0bf3c7c0 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 c3edfe5035..994414ffab 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 d71aaca391..cb1189c961 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 97ea5efd19..6018f90a65 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 c6425af206..8ac032bf8a 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 96b9ba2b21..21554953d0 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,164 +5815,1729 @@ 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_CALL) - { -#if WASM_ENABLE_THREAD_MGR != 0 - CHECK_SUSPEND_FLAGS(); -#endif - fidx = read_uint32(frame_ip); -#if WASM_ENABLE_MULTI_MODULE != 0 - if (fidx >= module->e->function_count) { - wasm_set_exception(module, "unknown function"); - goto got_exception; - } -#endif - cur_func = module->e->functions + fidx; - goto call_func_from_interp; - } - -#if WASM_ENABLE_TAIL_CALL != 0 - HANDLE_OP(WASM_OP_RETURN_CALL) + HANDLE_OP(WASM_OP_SIMD_PREFIX) { -#if WASM_ENABLE_THREAD_MGR != 0 - CHECK_SUSPEND_FLAGS(); -#endif - fidx = read_uint32(frame_ip); -#if WASM_ENABLE_MULTI_MODULE != 0 - if (fidx >= module->e->function_count) { - wasm_set_exception(module, "unknown function"); - goto got_exception; - } -#endif - cur_func = module->e->functions + fidx; - goto call_func_from_return_call; - } -#endif /* WASM_ENABLE_TAIL_CALL */ + GET_OPCODE(); -#if WASM_ENABLE_LABELS_AS_VALUES == 0 - default: - wasm_set_exception(module, "unsupported opcode"); - goto got_exception; - } -#endif + 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) -#if WASM_ENABLE_LABELS_AS_VALUES != 0 - HANDLE_OP(WASM_OP_UNUSED_0x0a) -#if WASM_ENABLE_TAIL_CALL == 0 - HANDLE_OP(WASM_OP_RETURN_CALL) - HANDLE_OP(WASM_OP_RETURN_CALL_INDIRECT) -#endif -#if WASM_ENABLE_SHARED_MEMORY == 0 - HANDLE_OP(WASM_OP_ATOMIC_PREFIX) -#endif -#if WASM_ENABLE_REF_TYPES == 0 && WASM_ENABLE_GC == 0 - HANDLE_OP(WASM_OP_TABLE_GET) - HANDLE_OP(WASM_OP_TABLE_SET) - HANDLE_OP(WASM_OP_REF_NULL) - HANDLE_OP(WASM_OP_REF_IS_NULL) - HANDLE_OP(WASM_OP_REF_FUNC) -#endif -#if WASM_ENABLE_GC == 0 - /* SELECT_T is converted to SELECT or SELECT_64 */ - HANDLE_OP(WASM_OP_SELECT_T) - HANDLE_OP(WASM_OP_CALL_REF) - HANDLE_OP(WASM_OP_RETURN_CALL_REF) - HANDLE_OP(WASM_OP_REF_EQ) - HANDLE_OP(WASM_OP_REF_AS_NON_NULL) - HANDLE_OP(WASM_OP_BR_ON_NULL) - HANDLE_OP(WASM_OP_BR_ON_NON_NULL) - HANDLE_OP(WASM_OP_GC_PREFIX) -#endif -#if WASM_ENABLE_EXCE_HANDLING == 0 - /* if exception handling is disabled, these opcodes issue a trap */ - HANDLE_OP(WASM_OP_TRY) - HANDLE_OP(WASM_OP_CATCH) - HANDLE_OP(WASM_OP_THROW) - HANDLE_OP(WASM_OP_RETHROW) - HANDLE_OP(WASM_OP_DELEGATE) - HANDLE_OP(WASM_OP_CATCH_ALL) - HANDLE_OP(EXT_OP_TRY) -#endif - HANDLE_OP(WASM_OP_UNUSED_0x16) - HANDLE_OP(WASM_OP_UNUSED_0x17) - HANDLE_OP(WASM_OP_UNUSED_0x27) - /* optimized op code */ - HANDLE_OP(WASM_OP_F32_STORE) - HANDLE_OP(WASM_OP_F64_STORE) - HANDLE_OP(WASM_OP_F32_LOAD) - HANDLE_OP(WASM_OP_F64_LOAD) - HANDLE_OP(EXT_OP_GET_LOCAL_FAST) - HANDLE_OP(WASM_OP_GET_LOCAL) - HANDLE_OP(WASM_OP_DROP) - HANDLE_OP(WASM_OP_DROP_64) - HANDLE_OP(WASM_OP_BLOCK) - HANDLE_OP(WASM_OP_LOOP) - HANDLE_OP(WASM_OP_END) - HANDLE_OP(WASM_OP_NOP) - HANDLE_OP(EXT_OP_BLOCK) - HANDLE_OP(EXT_OP_LOOP) - HANDLE_OP(EXT_OP_IF) - HANDLE_OP(EXT_OP_BR_TABLE_CACHE) - { - wasm_set_exception(module, "unsupported opcode"); - goto got_exception; - } -#endif + 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(); -#if WASM_ENABLE_LABELS_AS_VALUES == 0 - continue; -#else - FETCH_OPCODE_AND_DISPATCH(); -#endif + CHECK_MEMORY_OVERFLOW(16); + STORE_V128(maddr, data); + break; + } -#if WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 - call_func_from_return_call: - { - uint32 *lp_base = NULL, *lp = NULL; - int i; + /* Basic */ + case SIMD_v128_const: + { + uint8 *orig_ip = frame_ip; - if (cur_func->param_cell_num > 0 - && !(lp_base = lp = wasm_runtime_malloc(cur_func->param_cell_num - * sizeof(uint32)))) { - wasm_set_exception(module, "allocate memory failed"); - goto got_exception; - } - 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) { - PUT_I64_TO_ADDR( - lp, GET_OPERAND(uint64, I64, - 2 * (cur_func->param_count - i - 1))); - lp += 2; - } - else { - *lp = GET_OPERAND(uint32, I32, - (2 * (cur_func->param_count - i - 1))); - lp++; - } - } - frame->lp = frame->operand + cur_func->const_cell_num; - if (lp - lp_base > 0) { - word_copy(frame->lp, lp_base, lp - lp_base); - } - if (lp_base) - wasm_runtime_free(lp_base); - FREE_FRAME(exec_env, frame); - frame_ip += cur_func->param_count * sizeof(int16); - wasm_exec_env_set_cur_frame(exec_env, (WASMRuntimeFrame *)prev_frame); - is_return_call = true; - goto call_func_from_entry; - } -#endif /* WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 */ + frame_ip += sizeof(V128); + addr_ret = GET_OFFSET(); - call_func_from_interp: - { - /* Only do the copy when it's called from interpreter. */ - WASMInterpFrame *outs_area = wasm_exec_env_wasm_stack_top(exec_env); - int i; + 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]; + } + } -#if WASM_ENABLE_MULTI_MODULE != 0 + 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) + { +#if WASM_ENABLE_THREAD_MGR != 0 + CHECK_SUSPEND_FLAGS(); +#endif + fidx = read_uint32(frame_ip); +#if WASM_ENABLE_MULTI_MODULE != 0 + if (fidx >= module->e->function_count) { + wasm_set_exception(module, "unknown function"); + goto got_exception; + } +#endif + cur_func = module->e->functions + fidx; + goto call_func_from_interp; + } + +#if WASM_ENABLE_TAIL_CALL != 0 + HANDLE_OP(WASM_OP_RETURN_CALL) + { +#if WASM_ENABLE_THREAD_MGR != 0 + CHECK_SUSPEND_FLAGS(); +#endif + fidx = read_uint32(frame_ip); +#if WASM_ENABLE_MULTI_MODULE != 0 + if (fidx >= module->e->function_count) { + wasm_set_exception(module, "unknown function"); + goto got_exception; + } +#endif + cur_func = module->e->functions + fidx; + goto call_func_from_return_call; + } +#endif /* WASM_ENABLE_TAIL_CALL */ + +#if WASM_ENABLE_LABELS_AS_VALUES == 0 + default: + wasm_set_exception(module, "unsupported opcode"); + goto got_exception; + } +#endif + +#if WASM_ENABLE_LABELS_AS_VALUES != 0 + HANDLE_OP(WASM_OP_UNUSED_0x0a) +#if WASM_ENABLE_TAIL_CALL == 0 + HANDLE_OP(WASM_OP_RETURN_CALL) + HANDLE_OP(WASM_OP_RETURN_CALL_INDIRECT) +#endif +#if WASM_ENABLE_SHARED_MEMORY == 0 + HANDLE_OP(WASM_OP_ATOMIC_PREFIX) +#endif +#if WASM_ENABLE_REF_TYPES == 0 && WASM_ENABLE_GC == 0 + HANDLE_OP(WASM_OP_TABLE_GET) + HANDLE_OP(WASM_OP_TABLE_SET) + HANDLE_OP(WASM_OP_REF_NULL) + HANDLE_OP(WASM_OP_REF_IS_NULL) + HANDLE_OP(WASM_OP_REF_FUNC) +#endif +#if WASM_ENABLE_GC == 0 + /* SELECT_T is converted to SELECT or SELECT_64 */ + HANDLE_OP(WASM_OP_SELECT_T) + HANDLE_OP(WASM_OP_CALL_REF) + HANDLE_OP(WASM_OP_RETURN_CALL_REF) + HANDLE_OP(WASM_OP_REF_EQ) + HANDLE_OP(WASM_OP_REF_AS_NON_NULL) + HANDLE_OP(WASM_OP_BR_ON_NULL) + HANDLE_OP(WASM_OP_BR_ON_NON_NULL) + HANDLE_OP(WASM_OP_GC_PREFIX) +#endif +#if WASM_ENABLE_EXCE_HANDLING == 0 + /* if exception handling is disabled, these opcodes issue a trap */ + HANDLE_OP(WASM_OP_TRY) + HANDLE_OP(WASM_OP_CATCH) + HANDLE_OP(WASM_OP_THROW) + HANDLE_OP(WASM_OP_RETHROW) + HANDLE_OP(WASM_OP_DELEGATE) + HANDLE_OP(WASM_OP_CATCH_ALL) + HANDLE_OP(EXT_OP_TRY) +#endif + HANDLE_OP(WASM_OP_UNUSED_0x16) + HANDLE_OP(WASM_OP_UNUSED_0x17) + HANDLE_OP(WASM_OP_UNUSED_0x27) + /* optimized op code */ + HANDLE_OP(WASM_OP_F32_STORE) + HANDLE_OP(WASM_OP_F64_STORE) + HANDLE_OP(WASM_OP_F32_LOAD) + HANDLE_OP(WASM_OP_F64_LOAD) + HANDLE_OP(EXT_OP_GET_LOCAL_FAST) + HANDLE_OP(WASM_OP_GET_LOCAL) + HANDLE_OP(WASM_OP_DROP) + HANDLE_OP(WASM_OP_DROP_64) + HANDLE_OP(WASM_OP_BLOCK) + HANDLE_OP(WASM_OP_LOOP) + HANDLE_OP(WASM_OP_END) + HANDLE_OP(WASM_OP_NOP) + HANDLE_OP(EXT_OP_BLOCK) + HANDLE_OP(EXT_OP_LOOP) + HANDLE_OP(EXT_OP_IF) + HANDLE_OP(EXT_OP_BR_TABLE_CACHE) + { + wasm_set_exception(module, "unsupported opcode"); + goto got_exception; + } +#endif + +#if WASM_ENABLE_LABELS_AS_VALUES == 0 + continue; +#else + FETCH_OPCODE_AND_DISPATCH(); +#endif + +#if WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 + call_func_from_return_call: + { + uint32 *lp_base = NULL, *lp = NULL; + int i; + + if (cur_func->param_cell_num > 0 + && !(lp_base = lp = wasm_runtime_malloc(cur_func->param_cell_num + * sizeof(uint32)))) { + wasm_set_exception(module, "allocate memory failed"); + goto got_exception; + } + 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) { + PUT_I64_TO_ADDR( + lp, GET_OPERAND(uint64, I64, + 2 * (cur_func->param_count - i - 1))); + lp += 2; + } + else { + *lp = GET_OPERAND(uint32, I32, + (2 * (cur_func->param_count - i - 1))); + lp++; + } + } + frame->lp = frame->operand + cur_func->const_cell_num; + if (lp - lp_base > 0) { + word_copy(frame->lp, lp_base, lp - lp_base); + } + if (lp_base) + wasm_runtime_free(lp_base); + FREE_FRAME(exec_env, frame); + frame_ip += cur_func->param_count * sizeof(int16); + wasm_exec_env_set_cur_frame(exec_env, (WASMRuntimeFrame *)prev_frame); + is_return_call = true; + goto call_func_from_entry; + } +#endif /* WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 */ + + call_func_from_interp: + { + /* Only do the copy when it's called from interpreter. */ + WASMInterpFrame *outs_area = wasm_exec_env_wasm_stack_top(exec_env); + int i; + +#if WASM_ENABLE_MULTI_MODULE != 0 if (cur_func->is_import_func) { outs_area->lp = outs_area->operand + (cur_func->import_func_inst @@ -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 31424d21e9..29813d8759 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } } + 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } #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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 76647454be..9660bb1236 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 0000000000..eeb0e8d1f2 --- /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 b8cfcc989d..36b15e5688 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 31f8b3746b..183033751a 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 154/431] 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 0000000000..bc05d7b784 --- /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 c82501fad4..bb9004bc6f 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 9975dab7b3..bbe83cc644 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 155/431] 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 | 312 ++++++++++-------- tests/wamr-test-suites/test_wamr.sh | 26 +- 5 files changed, 194 insertions(+), 154 deletions(-) diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index a0b4535f9c..919a1f56c8 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 421b0bdb24..800ba37504 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 fe694124ad..91f9e5649a 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 6e963bdc74..427da39961 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 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 @@ def _read_stdout_byte(self) -> Tuple[bool, Optional[bytes]]: # 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 @@ def read_to_prompt(self, prompts, timeout): 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, 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) - - # 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)): - os.remove(t) + try: + if not opts.no_cleanup: + # remove the files under /tempfiles/ and copy of .wasm files + log(f"Removing {temp_file_repo}") - log("### End testing %s" % opts.test_file.name) - else: - log("Leaving tempfiles: %s" % ([wast_tempfile, wasm_tempfile])) + for t in temp_file_repo: + # 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(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 183033751a..7a4ca08b51 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 156/431] 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 | 3474 +++++++++-------- .../wasm-mutator-fuzz/portal/package.json | 4 +- 2 files changed, 1856 insertions(+), 1622 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json b/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json index 3abb540a2b..87dc143d04 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==", - "dev": true, - "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", + "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.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,221 +142,134 @@ } }, "node_modules/@babel/generator": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", - "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", - "dev": true, - "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==", + "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.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==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.18.8", - "@babel/helper-validator-option": "^7.18.6", - "browserslist": "^4.20.2", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@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==", + "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/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" }, "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==", + "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/types": "^7.18.6" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "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==", + "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-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" }, "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==", - "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" + "peerDependencies": { + "@babel/core": "^7.0.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==", + "node_modules/@babel/helper-plugin-utils": { + "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, - "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" + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" }, "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==", + "node_modules/@babel/parser": { + "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/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "@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==", - "dev": true, "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==", - "dev": true, - "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", + "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.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,734 +376,1113 @@ "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": [ - "linux" + "aix" ], "engines": { - "node": ">=12" + "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==", + "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, - "dependencies": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" - }, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], "engines": { - "node": ">=6.0.0" + "node": ">=18" } }, - "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==", + "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": ">=6.0.0" + "node": ">=18" } }, - "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==", + "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": ">=6.0.0" + "node": ">=18" } }, - "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 + "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/@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==", + "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, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" } }, - "node_modules/@types/prop-types": { - "version": "15.7.5", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", - "dev": true + "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/@types/react": { - "version": "18.0.17", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.17.tgz", - "integrity": "sha512-38ETy4tL+rn4uQQi7mB81G7V1g0u2ryquNmsVIOKUAEIDK+3CUjZ6rSRpdvS99dNBnkLFL83qfmtLacGOTIhwQ==", + "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, - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" } }, - "node_modules/@types/react-dom": { - "version": "18.0.6", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.6.tgz", - "integrity": "sha512-/5OFZgfIPSwy+YuIBP/FgJnQnsxhZhjjrnxudMddeblOouIodEQ75X14Rr4wGSG/bknL+Omy9iWlLo1u/9GzAA==", + "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, - "dependencies": { - "@types/react": "*" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "node_modules/@types/scheduler": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", - "dev": true + "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/@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==", + "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, - "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" - }, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "peerDependencies": { - "vite": "^3.0.0" + "node": ">=18" } }, - "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==", + "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, - "dependencies": { - "color-convert": "^1.9.0" - }, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=4" + "node": ">=18" } }, - "node_modules/antd": { - "version": "4.22.8", - "resolved": "https://registry.npmjs.org/antd/-/antd-4.22.8.tgz", - "integrity": "sha512-mqHuCg9itZX+z6wk+mvRBcfz/U9iiIXS4LoNkyo8X/UBgdN8CoetFmrdvA1UQy1BuWa0/n62LiS1LatdvoTuHw==", - "dependencies": { - "@ant-design/colors": "^6.0.0", - "@ant-design/icons": "^4.7.0", - "@ant-design/react-slick": "~0.29.1", - "@babel/runtime": "^7.18.3", - "@ctrl/tinycolor": "^3.4.0", - "classnames": "^2.2.6", - "copy-to-clipboard": "^3.2.0", - "lodash": "^4.17.21", - "memoize-one": "^6.0.0", - "moment": "^2.29.2", - "rc-cascader": "~3.6.0", - "rc-checkbox": "~2.3.0", - "rc-collapse": "~3.3.0", - "rc-dialog": "~8.9.0", - "rc-drawer": "~5.1.0", - "rc-dropdown": "~4.0.0", - "rc-field-form": "~1.27.0", - "rc-image": "~5.7.0", - "rc-input": "~0.0.1-alpha.5", - "rc-input-number": "~7.3.5", - "rc-mentions": "~1.9.1", - "rc-menu": "~9.6.3", - "rc-motion": "^2.6.1", - "rc-notification": "~4.6.0", - "rc-pagination": "~3.1.17", - "rc-picker": "~2.6.10", - "rc-progress": "~3.3.2", - "rc-rate": "~2.9.0", - "rc-resize-observer": "^1.2.0", - "rc-segmented": "~2.1.0", - "rc-select": "~14.1.1", - "rc-slider": "~10.0.0", - "rc-steps": "~4.1.0", - "rc-switch": "~3.2.0", - "rc-table": "~7.25.3", - "rc-tabs": "~11.16.0", - "rc-textarea": "~0.3.0", - "rc-tooltip": "~5.2.0", - "rc-tree": "~5.6.5", - "rc-tree-select": "~5.4.0", - "rc-trigger": "^5.2.10", - "rc-upload": "~4.3.0", - "rc-util": "^5.22.5", - "scroll-into-view-if-needed": "^2.2.25" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/ant-design" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/array-tree-filter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-tree-filter/-/array-tree-filter-2.1.0.tgz", - "integrity": "sha512-4ROwICNlNw/Hqa9v+rk5h22KjmzB1JGTMVKP2AKJBOCgb0yL0ASf0+YvCcLNNwquOHNX48jkeZIJ3a+oOQqKcw==" - }, - "node_modules/async-validator": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz", - "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==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001370", - "electron-to-chromium": "^1.4.202", - "node-releases": "^2.0.6", - "update-browserslist-db": "^1.0.5" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "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==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - } - ] - }, - "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" - } - }, - "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==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.1" - } - }, - "node_modules/copy-to-clipboard": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.2.tgz", - "integrity": "sha512-Vme1Z6RUDzrb6xAI7EZlVZ5uvOk2F//GaxKUxajDqm9LhOVM1inxNAD2vy+UZDYsd0uyA9s7b3/FVZPSxqrCfg==", - "dependencies": { - "toggle-selection": "^1.0.6" - } - }, - "node_modules/csstype": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz", - "integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==", - "dev": true - }, - "node_modules/date-fns": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.2.tgz", - "integrity": "sha512-0VNbwmWJDS/G3ySwFSJA3ayhbURMTJLtwM2DTxf9CWondCnh6DTNlO9JgRSq6ibf4eD0lfMJNBxUdEAHHix+bA==", - "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" - } - }, - "node_modules/dayjs": { - "version": "1.11.5", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", - "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==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/dom-align": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/dom-align/-/dom-align-1.12.3.tgz", - "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 - }, - "node_modules/esbuild": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz", - "integrity": "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==", - "dev": true, - "hasInstallScript": true, - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=12" - }, - "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==", + "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": [ - "x64" + "mips64el" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "android" + "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "arm64" + "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "android" + "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "x64" + "riscv64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "darwin" + "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "arm64" + "s390x" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "darwin" + "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "freebsd" + "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "freebsd" + "netbsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "ia32" + "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "netbsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "x64" + "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "openbsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "arm" + "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "openbsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "arm64" + "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "sunos" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "mips64el" + "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "ppc64" + "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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==", + "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": [ - "riscv64" + "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, - "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" - ], + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, - "optional": true, - "os": [ - "linux" - ], + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, "engines": { - "node": ">=12" + "node": ">=6.0.0" } }, - "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" - ], + "node_modules/@jridgewell/resolve-uri": { + "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, - "optional": true, - "os": [ - "netbsd" - ], + "license": "MIT", "engines": { - "node": ">=12" + "node": ">=6.0.0" } }, - "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" - ], + "node_modules/@jridgewell/set-array": { + "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, - "optional": true, - "os": [ - "openbsd" - ], + "license": "MIT", "engines": { - "node": ">=12" + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "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.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.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "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==", + "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": [ - "sunos" + "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" ], - "engines": { - "node": ">=12" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] }, - "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==", + "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": [ - "ia32" + "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ - "win32" + "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" ], - "engines": { - "node": ">=12" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] }, - "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==", + "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": [ - "win32" + "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" ], - "engines": { - "node": ">=12" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] }, - "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==", + "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", + "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", + "dev": true + }, + "node_modules/@types/react": { + "version": "18.0.17", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.17.tgz", + "integrity": "sha512-38ETy4tL+rn4uQQi7mB81G7V1g0u2ryquNmsVIOKUAEIDK+3CUjZ6rSRpdvS99dNBnkLFL83qfmtLacGOTIhwQ==", + "dev": true, + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.0.6", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.6.tgz", + "integrity": "sha512-/5OFZgfIPSwy+YuIBP/FgJnQnsxhZhjjrnxudMddeblOouIodEQ75X14Rr4wGSG/bknL+Omy9iWlLo1u/9GzAA==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, + "node_modules/@types/scheduler": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", + "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", + "dev": true + }, + "node_modules/@vitejs/plugin-react": { + "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.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": ">=12" + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0" } }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "node_modules/antd": { + "version": "4.22.8", + "resolved": "https://registry.npmjs.org/antd/-/antd-4.22.8.tgz", + "integrity": "sha512-mqHuCg9itZX+z6wk+mvRBcfz/U9iiIXS4LoNkyo8X/UBgdN8CoetFmrdvA1UQy1BuWa0/n62LiS1LatdvoTuHw==", + "dependencies": { + "@ant-design/colors": "^6.0.0", + "@ant-design/icons": "^4.7.0", + "@ant-design/react-slick": "~0.29.1", + "@babel/runtime": "^7.18.3", + "@ctrl/tinycolor": "^3.4.0", + "classnames": "^2.2.6", + "copy-to-clipboard": "^3.2.0", + "lodash": "^4.17.21", + "memoize-one": "^6.0.0", + "moment": "^2.29.2", + "rc-cascader": "~3.6.0", + "rc-checkbox": "~2.3.0", + "rc-collapse": "~3.3.0", + "rc-dialog": "~8.9.0", + "rc-drawer": "~5.1.0", + "rc-dropdown": "~4.0.0", + "rc-field-form": "~1.27.0", + "rc-image": "~5.7.0", + "rc-input": "~0.0.1-alpha.5", + "rc-input-number": "~7.3.5", + "rc-mentions": "~1.9.1", + "rc-menu": "~9.6.3", + "rc-motion": "^2.6.1", + "rc-notification": "~4.6.0", + "rc-pagination": "~3.1.17", + "rc-picker": "~2.6.10", + "rc-progress": "~3.3.2", + "rc-rate": "~2.9.0", + "rc-resize-observer": "^1.2.0", + "rc-segmented": "~2.1.0", + "rc-select": "~14.1.1", + "rc-slider": "~10.0.0", + "rc-steps": "~4.1.0", + "rc-switch": "~3.2.0", + "rc-table": "~7.25.3", + "rc-tabs": "~11.16.0", + "rc-textarea": "~0.3.0", + "rc-tooltip": "~5.2.0", + "rc-tree": "~5.6.5", + "rc-tree-select": "~5.4.0", + "rc-trigger": "^5.2.10", + "rc-upload": "~4.3.0", + "rc-util": "^5.22.5", + "scroll-into-view-if-needed": "^2.2.25" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ant-design" + }, + "peerDependencies": { + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + } + }, + "node_modules/array-tree-filter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-tree-filter/-/array-tree-filter-2.1.0.tgz", + "integrity": "sha512-4ROwICNlNw/Hqa9v+rk5h22KjmzB1JGTMVKP2AKJBOCgb0yL0ASf0+YvCcLNNwquOHNX48jkeZIJ3a+oOQqKcw==" + }, + "node_modules/async-validator": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz", + "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" + }, + "node_modules/browserslist": { + "version": "4.24.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", + "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "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.30001688", + "electron-to-chromium": "^1.5.73", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.1" + }, + "bin": { + "browserslist": "cli.js" + }, "engines": { - "node": ">=6" + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "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": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "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/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": "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, + "license": "MIT" + }, + "node_modules/copy-to-clipboard": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.2.tgz", + "integrity": "sha512-Vme1Z6RUDzrb6xAI7EZlVZ5uvOk2F//GaxKUxajDqm9LhOVM1inxNAD2vy+UZDYsd0uyA9s7b3/FVZPSxqrCfg==", + "dependencies": { + "toggle-selection": "^1.0.6" + } + }, + "node_modules/csstype": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz", + "integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==", + "dev": true + }, + "node_modules/date-fns": { + "version": "2.29.2", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.2.tgz", + "integrity": "sha512-0VNbwmWJDS/G3ySwFSJA3ayhbURMTJLtwM2DTxf9CWondCnh6DTNlO9JgRSq6ibf4eD0lfMJNBxUdEAHHix+bA==", + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" } }, - "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==", + "node_modules/dayjs": { + "version": "1.11.5", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", + "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==" + }, + "node_modules/debug": { + "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.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dom-align": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/dom-align/-/dom-align-1.12.3.tgz", + "integrity": "sha512-Gj9hZN3a07cbR6zviMUBOMPdWxYhbMI+x+WS0NAIu2zFZmbK8ys9R79g+iG9qLnlCwpFoaB+fKy8Pdv470GsPA==" + }, + "node_modules/electron-to-chromium": { + "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.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": ">=18" + }, + "optionalDependencies": { + "@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.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, + "license": "MIT", "engines": { - "node": ">=0.8.0" + "node": ">=6" } }, "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==", + "node_modules/rollup": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.36.0.tgz", + "integrity": "sha512-zwATAXNQxUcd40zgtQG0ZafcRK4g004WtEl7kbuhTWPvf07PsfohXl39jVUvPF7jvNAIkKPQ2XrsDlWuxBd++Q==", "dev": true, + "license": "MIT", "dependencies": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" + "@types/estree": "1.0.6" }, - "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==", - "dev": true, "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": { @@ -2403,356 +2633,597 @@ "resize-observer-polyfill": "^1.5.1" } }, - "@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==", + "@babel/code-frame": { + "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/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + } + }, + "@babel/compat-data": { + "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.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.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.3", + "semver": "^6.3.1" + } + }, + "@babel/generator": { + "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/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.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.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.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/traverse": "^7.25.9", + "@babel/types": "^7.25.9" + } + }, + "@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, + "requires": { + "@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.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-string-parser": { + "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.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.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.26.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", + "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", + "dev": true, + "requires": { + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" + } + }, + "@babel/parser": { + "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/types": "^7.26.10" + } + }, + "@babel/plugin-transform-react-jsx-self": { + "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.25.9" + } + }, + "@babel/plugin-transform-react-jsx-source": { + "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.25.9" + } + }, + "@babel/runtime": { + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz", + "integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==", + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/template": { + "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.26.2", + "@babel/parser": "^7.26.9", + "@babel/types": "^7.26.9" + } + }, + "@babel/traverse": { + "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.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.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.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + } + }, + "@ctrl/tinycolor": { + "version": "3.4.1", + "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.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.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" } }, - "@babel/compat-data": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.13.tgz", - "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==", + "@jridgewell/resolve-uri": { + "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 }, - "@babel/core": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.13.tgz", - "integrity": "sha512-ZisbOvRRusFktksHSG6pjj1CSvkPkcZq/KHD45LAkVP/oiHJkNBZWfpvlLmX8OtHDG8IuzsFlVRWo08w7Qxn0A==", - "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", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.1", - "semver": "^6.3.0" - } + "@jridgewell/set-array": { + "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 }, - "@babel/generator": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", - "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", - "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" - } - } - } + "@jridgewell/sourcemap-codec": { + "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 }, - "@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==", + "@jridgewell/trace-mapping": { + "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": { - "@babel/types": "^7.18.6" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "@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==", + "@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, - "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 + "optional": 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==", + "@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, - "requires": { - "@babel/template": "^7.18.6", - "@babel/types": "^7.18.9" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/types": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/types": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "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" - } + "optional": true }, - "@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==", - "dev": 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 }, - "@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==", + "@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, - "requires": { - "@babel/types": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/types": "^7.18.6" - } + "optional": true }, - "@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==", - "dev": 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 }, - "@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==", - "dev": 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 }, - "@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==", - "dev": 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 }, - "@babel/helpers": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz", - "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==", + "@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, - "requires": { - "@babel/template": "^7.18.6", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9" - } + "optional": true }, - "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "@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, - "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } + "optional": true }, - "@babel/parser": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.13.tgz", - "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==", - "dev": 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 }, - "@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==", + "@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, - "requires": { - "@babel/helper-plugin-utils": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "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" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/plugin-transform-react-jsx": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/helper-plugin-utils": "^7.18.6" - } + "optional": true }, - "@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==", + "@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, - "requires": { - "@babel/helper-plugin-utils": "^7.18.6" - } + "optional": true }, - "@babel/runtime": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz", - "integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==", + "@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": { - "regenerator-runtime": "^0.13.4" + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" } }, - "@babel/template": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", - "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", + "@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/code-frame": "^7.18.6", - "@babel/parser": "^7.18.10", - "@babel/types": "^7.18.10" - } - }, - "@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==", - "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", - "globals": "^11.1.0" + "@babel/types": "^7.0.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==", + "@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/helper-string-parser": "^7.18.10", - "@babel/helper-validator-identifier": "^7.18.6", - "to-fast-properties": "^2.0.0" + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" } }, - "@ctrl/tinycolor": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz", - "integrity": "sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==" - }, - "@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==", - "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==", + "@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": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@babel/types": "^7.20.7" } }, - "@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==", - "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==", - "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==", + "@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 }, - "@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==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "@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==", - "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==", + "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": { - "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==", - "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-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==", + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", + "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", "dev": true, - "optional": true + "requires": { + "@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" + } }, "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 01622ddf5a..5019af623e 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 157/431] =?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 ef0799b42b..5922f5e3a9 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 eabe017889..1c2dceadfe 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 158/431] 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 dcefb7e845..171adb3446 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 159/431] 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 dae8190f11..55a72f170f 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 2a378c8790..89a98f6155 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 160/431] 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 55a72f170f..c0dd58986f 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 1c2dceadfe..6c36c45ca3 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 89a98f6155..e2de616042 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 161/431] 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 91f9e5649a..2c4725e89f 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 162/431] 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 171adb3446..7a28005d41 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 163/431] 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 36b15e5688..6425450bd6 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 164/431] 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 c0dd58986f..534f8e356c 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 e2de616042..b691679b1d 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 165/431] 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 334f4bb6c1..f08f766168 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 166/431] 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 e6d1c840a7..551991f891 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 6bec45d1e7..25fe491ea6 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 8ddddffeba..c6a4430f7f 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 ef9bea9e24..2cea780690 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 b41fe0a515..6131b69772 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 8472df8dd8..309949a20b 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 5640a384a0..fccc523236 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 927e6f4592..bc3bde5657 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 a29dbd69c1..5104769d73 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 c32a0b9777..cc98146c57 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 dd03cb356f..3f08a72ad0 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 5fcc276a19..9ec5d34152 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 78dd322858..46dc3ea0c5 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 16c9b26dc0..8e7b819b16 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 7c68a71ac7..347fddf3ed 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 f690527421..177cf2c5eb 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 c3a69ccc86..fca2003765 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 4af87a3fdd..f63485ca03 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 f157dfbde5..9f3e49db9c 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 8dbb52686c..6460a99e67 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 ffcd9005ab..e5bea6010b 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 3f5f23e97c..48ff9ee569 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 afba7dfb6d..93907b7f0d 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 8f11e0a6b4..38e8139168 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 d322b42b66..744f72c3c8 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 81d998bc83..a6298c5e10 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 167/431] 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 b96bcd1bf4..701929996d 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 168/431] 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 245c7a6515..5f62abf24d 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 c3dfa6bf11..fa5c2ab955 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 169/431] 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 edbfb62f7e..997a82e41e 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 170/431] 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 534f8e356c..098bd7f9c7 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 b691679b1d..f0230c23eb 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 171/431] 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 5f62abf24d..252ef7056e 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 6a456efdac..f065a5ad20 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 f7ada4d8df..ca9ba17f1f 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 1f37060d91..492c3048c7 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 @@ compile_op_int_bitwise(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, } 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 172/431] 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 20b1ad526c..f322b3c1e1 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 fdbe971d26..133b191858 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 3637bc3714..489e6e59f0 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 filter_output(output: str) -> str: 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 173/431] 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 ecda490dfe..af9ea50461 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 174/431] 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 2c0bf3c7c0..1cb50235ce 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 29813d8759..8229c6f71d 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 893dd56383..2d5a4b13ea 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 427da39961..ae418a60d1 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 @@ def recently_added_wasm(temp_file_repo): 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 @@ def recently_added_wasm(temp_file_repo): 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 7a4ca08b51..b28b2bedb1 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 175/431] 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 8229c6f71d..10a20e313b 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } } +#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 176/431] 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 21554953d0..aa0330568e 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 177/431] 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 10a20e313b..fc68e5966f 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -15624,7 +15624,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* 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 178/431] 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 098bd7f9c7..ab76a6b5de 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 f0230c23eb..39e868dd66 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 179/431] 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 bf7f51964f..55b6805025 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 64719f7f5f..3cc2afe04d 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 180/431] 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 83cd154afe..47f613ab2f 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 bb9004bc6f..e6d56c43f6 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 c5012bd36c..676258075f 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 e17a6b25af..36bad1c519 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 7a3bfbdce7..fefe0fca26 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 eeb0e8d1f2..60fd6d975d 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 6c921bbc93..c698e8c5f9 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 8f4f8d1aa7..29dd463901 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 d2b3f74e04..2561b52436 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 467f5fd1f9..11b58d2eac 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 c0c7622c9d..813afa21f8 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 5fa171a9cc..610de6afe6 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 c871877098..e75a81b338 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 9f7a69229f..fa9b400fac 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 9ff066f08c..cbdc62f659 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 9dd9565a5d..2becb77c97 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 6b9c70c888..bb2216bddf 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 0941a39ccf..65a9dfbdaa 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 1529d0ea6b..747a8b1263 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 a539dd2361..6455db554d 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 e0f70d1427..6d9670dfe5 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 c99908b2ed..f0a1d5e22a 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 4d88760e79..f39ed44444 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 549b70ad6c..02e96c6d10 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 03e1616d74..a899b8fbe4 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 f737569151..21e5a917f2 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 c5a43dd0e0..47b6b835ba 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 90ea2eb7cd..66c50b7e8c 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 3b8884e111..9448cd8c36 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 d13d65aac5..6242a48b99 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 181/431] 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 55b6805025..b2c9ed6281 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 0a423c398c..f7f2421f48 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 ecb75968fc..a41e0da339 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 182/431] 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 0ffc78ad92..340e657e8b 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 68738213ef..275eeaad13 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 fbd876ac33..2cf1e686a3 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 9e279a2e62..41ed94dec1 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 905ca2f7c2..a5267d770a 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 af2566da59..698663c7b2 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 183/431] 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 4ebb1d799e..67cb8fc238 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 184/431] 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 0000000000..17757573d6 --- /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 e4b7732bc3..97e665c0bb 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 5692377782..b1f59ce3b9 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 b865a59fe2..836f5c747e 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 dacdbc42d7..dec06e3270 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 031d578841..ad751f8708 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 919a1f56c8..5432080f1a 100644 --- a/ci/coding_guidelines_check.py +++ b/ci/coding_guidelines_check.py @@ -13,8 +13,8 @@ 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 @@ "**/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 ae418a60d1..8de001af60 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 @@ def recently_added_wasm(temp_file_repo): 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 b28b2bedb1..57cef635f3 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 185/431] 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 d504e984c8..41ac4c7248 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 aa0330568e..f02f3f2f0e 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 186/431] 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 701929996d..b072c9851f 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 @@ aot_create_perf_map(const AOTModule *module, char *error_buf, 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 187/431] 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 0000000000..c872e42522 --- /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 47f613ab2f..dd6c096f11 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 66938905cc..cf5578cfbf 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 836f5c747e..541f7a2840 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 dec06e3270..92b8f55192 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 bc3bde5657..af911a0db0 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 0caf374dfa..65b9647d90 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 411106bb30..512507d6ee 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 527b5f37aa..9858b98dab 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 fca2003765..a5184718bf 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 f63485ca03..a80f0c8f03 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 e9882c835f..efcc8c07e8 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 5cdfea41e4..0000000000 --- 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 11b58d2eac..08cc3a7ffb 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 87f21e9fd5..27e06b6349 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 188/431] 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 21554953d0..042a06da5d 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1013,6 +1013,22 @@ copy_stack_values(WASMModuleInstance *module, uint32 *frame_lp, uint32 arity, 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 @@ copy_stack_values(WASMModuleInstance *module, uint32 *frame_lp, uint32 arity, 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 189/431] 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 d26c460fed..e48645d8ca 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 190/431] 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 | 210 +++++++++--------- 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, 250 insertions(+), 290 deletions(-) diff --git a/tests/unit/aot-stack-frame/CMakeLists.txt b/tests/unit/aot-stack-frame/CMakeLists.txt index cbdc62f659..90a61aea76 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 9bea2b2a03..bcc1e246c2 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 2becb77c97..6c43a41844 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 1b4941787d..adc9640e72 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 4df02ce8fc..e551b14b48 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 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 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 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 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 $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 $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 $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 $t4 (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 (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 (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 (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 (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 (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 (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 (ref $t2) (table.get (i32.const 2))))) + + (br_if $l (i32.eqz (ref.test (ref $t3) (table.get (i32.const 3))))) + + (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 $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 $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 $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 $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 $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 (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 (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 (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 (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 8bf02e4307..eeec11faa1 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 895473ce31..f74da50e8c 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 191/431] 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 fa5dcb2c34..2790a12eba 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 e85e869c28..7537216dce 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 192/431] 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 e6770eb45d..35b25c8300 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 193/431] 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 ccbccd1e00..5e1fdf6ce6 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 194/431] 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 a9fd68c244..21e675bc7a 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 9c608d301e..6b1233c39f 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 fda17d5a7e..8391766232 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 3efe344e6a..312231619a 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 195/431] 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 | 227 ++++++------------ 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, 463 insertions(+), 174 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 04c4e1ccb0..21eaedca8c 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 21e675bc7a..9270f0efef 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 813afa21f8..8bb860788a 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) +# 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() + +# +# Global settings +# +set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) -string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) +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 () +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +# 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) + +# 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 () + endif() +endif() -if (APPLE) +if(APPLE) add_definitions(-DBH_PLATFORM_DARWIN) -endif () +endif() + +# Disable hardware bound check and enable AOT validator +set(WAMR_DISABLE_HW_BOUND_CHECK 1) +set(WAMR_BUILD_AOT_VALIDATOR 1) + +set(REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +message(STATUS "REPO_ROOT_DIR: ${REPO_ROOT_DIR}") + +# 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(CUSTOM_MUTATOR EQUAL 1) - add_compile_definitions(CUSTOM_MUTATOR) +# 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_INTERP) - # Enable Interpreter by default - set (WAMR_BUILD_INTERP 1) -endif () - -if (NOT DEFINED WAMR_BUILD_AOT) - # Enable AOT by default. - set (WAMR_BUILD_AOT 1) -endif () - -if (NOT DEFINED WAMR_BUILD_JIT) - # Disable JIT by default. - set (WAMR_BUILD_JIT 0) -endif () - -if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) - # Disable libc builtin support by default - set (WAMR_BUILD_LIBC_BUILTIN 0) -endif () - -if (NOT DEFINED WAMR_BUILD_LIBC_WASI) - # Enable libc wasi support by default - set (WAMR_BUILD_LIBC_WASI 0) -endif () - -if (NOT DEFINED WAMR_BUILD_FAST_INTERP) - # Enable fast interpreter - set (WAMR_BUILD_FAST_INTERP 1) -endif () - -if (NOT DEFINED WAMR_BUILD_MULTI_MODULE) - # Disable multiple modules - set (WAMR_BUILD_MULTI_MODULE 0) -endif () - -if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD) - # Disable pthread library by default - set (WAMR_BUILD_LIB_PTHREAD 0) -endif () - -if (NOT DEFINED WAMR_BUILD_MINI_LOADER) - # Disable wasm mini loader by default - set (WAMR_BUILD_MINI_LOADER 0) -endif () - -if (NOT DEFINED WAMR_BUILD_SIMD) - # Enable SIMD by default - set (WAMR_BUILD_SIMD 1) -endif () - -if (NOT DEFINED WAMR_BUILD_REF_TYPES) - # Enable reference type by default - set (WAMR_BUILD_REF_TYPES 1) -endif () - -if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP) - # Disable Debug feature by default - set (WAMR_BUILD_DEBUG_INTERP 0) -endif () - -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 () - -# 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}) - -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) +find_package(LLVM REQUIRED CONFIG) + +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + +include_directories(${LLVM_INCLUDE_DIRS}) +separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) +add_definitions(${LLVM_DEFINITIONS_LIST}) + +set(SHARED_DIR ${REPO_ROOT_DIR}/core/shared) +set(IWASM_DIR ${REPO_ROOT_DIR}/core/iwasm) + +# 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 acf210ae42..09fd757be4 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 0000000000..cf3caa16d6 --- /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 0000000000..e758cd9740 --- /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 0000000000..d16a0b2072 --- /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 0000000000..1e12be3a7f --- /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 196/431] 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 8bb860788a..60c6d92f2d 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 197/431] 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 60c6d92f2d..a6ff12d647 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 cf3caa16d6..82c0ab332d 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 1e12be3a7f..4d6ae0fa4e 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 198/431] 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 54cec530af..9ba5858425 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 8081f9fa44..bdaff68347 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 644544f08d..a89a116549 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 4f8e21ac85..fa5b59a1ba 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 52064ac449..a79ca33b57 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 199/431] 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 9ca64f9c82..ae66b3f705 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 a41e0da339..29c5828f41 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 200/431] 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 5432080f1a..43c3662590 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 201/431] 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 7a28005d41..da5bf86736 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 202/431] 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 9270f0efef..c1708e3f9d 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 312231619a..4d1a24b546 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 203/431] 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 252ef7056e..fcc2fda9d6 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 f065a5ad20..e54c82516a 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 204/431] 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 ab76a6b5de..7126e2d09b 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 39e868dd66..acc123c773 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 205/431] 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 b8783f4ae6..19c601889f 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 206/431] 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 fcc2fda9d6..a0e59e1d21 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 207/431] 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 fc68e5966f..ef4020a363 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 af9ea50461..23fb76370e 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 208/431] 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 29c5828f41..5a7ba9e74c 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 209/431] 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 19c601889f..06dc92d5ef 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 210/431] 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 38a4401440..b2ef1e1051 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 211/431] 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 ae66b3f705..13de3009dc 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 ef4020a363..4cdf6ea5cd 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 23fb76370e..30d540d565 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 b5663e3a29..a3752b4395 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 9ae0a03a20..d90f38ec5b 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 be50a2900d..4d78df38a0 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 12843b7c14..d57d0eac7c 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 9accc5eb8d..b48033247a 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 b9fd1f9fa0..f858f7eaed 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 770c5c741b..55ea77ac76 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 b383def674..3280e542f6 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 212/431] 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 801186e979..1571358802 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 213/431] 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 4cdf6ea5cd..13fd61e7c2 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 30d540d565..1ed91230f7 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 214/431] 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 5a7ba9e74c..097727d132 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 215/431] 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 1cb50235ce..7ded52fd91 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 715f2f3bdf..e2bbe54e84 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 12bbf79bc1..3c04d46ecf 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 216/431] 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 | 55 ++++++++++++------- samples/file/wasm-app/main.c | 2 +- 2 files changed, 35 insertions(+), 22 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 e48645d8ca..bef4c19f3c 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) { + + /* not truncated */ + if (bytes_read < buf_len) { buf[bytes_read] = '\0'; - *p_len = len; + *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 6e6204cca2..e794a273f3 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 217/431] 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 d8bcbd26c7..3d241355b4 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 8de001af60..158d759ed3 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 @@ 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 4d1a24b546..f74b2fb151 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 218/431] 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 a5267d770a..743165dd9e 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 219/431] 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 e33fd9f3a5..27484dfc59 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 220/431] 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 cf5578cfbf..b59f841c53 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 221/431] 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 13fd61e7c2..8fbfea36b8 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 222/431] 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 82c0ab332d..a613ea4e2d 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 e758cd9740..89b4bad0a9 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 223/431] 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 9ec5d34152..e0a4e255b9 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 224/431] 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 8fbfea36b8..a83de4a48c 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 225/431] 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 7ded52fd91..82d59ba2a1 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 994414ffab..d9459838e4 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 6018f90a65..dc80092058 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 f33ad60e3b..78b2f609e4 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 226/431] 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 | 46 ++++++++++++++------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release_process.yml b/.github/workflows/release_process.yml index ad751f8708..91f081fd21 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 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 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 }} # # 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 227/431] 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 b5cf53a4ce..297328cc5a 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 228/431] 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 9660bb1236..bb04d56f15 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 229/431] 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 541f7a2840..e6cc291081 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 230/431] 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 82f70ca3dc..5d9664ee8e 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 78b2f609e4..78f53e694f 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 a83de4a48c..db9afb0f24 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, *(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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, *(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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, 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 bb04d56f15..37d32b122f 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 231/431] 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 82d59ba2a1..5f7746f6a4 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 fefe0fca26..6919efba26 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 35d091e78d..59616daf6f 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 232/431] 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 | 713 ++++++++++++++++++++++++------------ build-scripts/version.cmake | 2 +- core/version.h | 2 +- 3 files changed, 481 insertions(+), 236 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e0bb032cf8..b39f55baeb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,45 +1,239 @@ +## WAMR-2.3.0 + +### Breaking changes + +### New features + +- simd for fast-interp (#4131) +- copy call-stack (#4033) + +### Bug fixes + +- 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 +### Breaking changes -### New features -- Add support for multi-memory proposal in classic interpreter (#3742) +### 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) +- 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) + +- 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 21eaedca8c..e34a118212 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 d1becac61f..00d212c5bf 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 233/431] 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 78f53e694f..681612380a 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 234/431] 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 | 44 ++++++++++++------- tests/unit/wasm-c-api/CMakeLists.txt | 4 +- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index dd6c096f11..521c2e08f6 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 fa9b400fac..8c963cadd8 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 6c43a41844..7d80bbfbff 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 +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 - && 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 + 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 - && 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 + 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 9448cd8c36..9556c600e1 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 235/431] 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 af0d8efc94..b47cd16abc 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 ff25b32cbf..a8083a7425 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 0000000000..eb71f09cd6 --- /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 7ce1b57a53..4b8d248cb9 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 236/431] 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 7126e2d09b..665c1588d5 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 acc123c773..2bc70f9bc6 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 237/431] 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 9a6f685c75..7d9c46f9d6 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 238/431] 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 521c2e08f6..db0200cac6 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 b59f841c53..44c7973f17 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 0000000000..6e97cb72c4 --- /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 0000000000..91b244fe20 --- /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 0000000000..a51c1849cd --- /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 239/431] 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 5f7746f6a4..1a77d4cac8 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 cb1189c961..a4e1499e35 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 27484dfc59..47752950f2 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 ce0c1fa7fa..5d80312fb1 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 d33c027273..b316a6e305 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 8ac032bf8a..64a6cd7936 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 b73a0364e7..b4ab34bea7 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 41ac4c7248..1e98b0fa91 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 681612380a..4e5edf41b6 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 6425450bd6..94dd96284e 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 240/431] 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 b316a6e305..1c1a200228 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 241/431] 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 551991f891..0a374b5d5a 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 594110a442..cd7c8bc88e 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 be0c57edef..cef8329d77 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 e0a4e255b9..1a1707f0c3 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 242/431] 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 6023b07020..ddc0b15b4e 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 db9afb0f24..6ef1ff5bf1 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } 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 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* 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 a6ff12d647..500ad8fe3c 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 a613ea4e2d..5ca33906a5 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 4d6ae0fa4e..b501baecf2 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 bbe83cc644..0ce6473944 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 243/431] 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 e05b30119d..fdeff30224 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" \ - .. - -RUN make -j "$(grep -c ^processor /proc/cpuinfo)" + && cmake --build build -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 244/431] 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 0a374b5d5a..88a1642b8e 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 d9459838e4..e538b5d914 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 1a1707f0c3..2a4017d686 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 c4d71d18ff..b55b6eb1d7 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 0ce6473944..da02ece00f 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 245/431] 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 13de3009dc..b875ab93c5 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 1c1a200228..dcee0aeafc 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 6ef1ff5bf1..40ea697a91 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 1ed91230f7..e66c08bab6 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 246/431] 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 b39f55baeb..8b3cfec28b 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 e34a118212..c98b10f6f6 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 00d212c5bf..85e0333909 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 247/431] 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 da02ece00f..0ce6473944 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 248/431] 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 | 41 ++++++++----------- core/iwasm/libraries/wasi-nn/test/utils.c | 5 ++- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index ad1f37deb5..c8d1217a77 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 4697e931b0..75f362c76f 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 f63d57e074..09e12f0d2d 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: - { + break; + } + case tpu: + { #if WASM_ENABLE_WASI_NN_EXTERNAL_DELEGATE != 0 - TfLiteExternalDelegateDelete(tfl_ctx->delegate); + TfLiteExternalDelegateDelete(tfl_ctx->delegate); #else - NN_ERR_PRINTF( - "External delegate delete but not enabled."); + NN_ERR_PRINTF("External delegate delete but not enabled."); #endif - break; - } - default: - break; + 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 9e43ec9854..690c37f0e7 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 249/431] 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 2bc70f9bc6..d9e10a71ce 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 250/431] 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 6919efba26..f197b21d64 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 59616daf6f..35d091e78d 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 251/431] 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 db2f91db0d..f8221d8d26 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 252/431] 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 75f362c76f..f3c92eff27 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 253/431] 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 99a7664676..2e926a0327 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 3ac694fc95..787cc6a5c2 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 f8221d8d26..4bd9b9ede1 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 254/431] 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 f3c92eff27..15f5fb5509 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 255/431] 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 4bd9b9ede1..dcfec1ccb8 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 256/431] 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 40ea697a91..6317badc55 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 257/431] 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 15f5fb5509..724485449f 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 258/431] 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 c8d1217a77..4a238e65eb 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 259/431] 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 787cc6a5c2..5a8136ca9f 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 260/431] 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 369980ba94..21f961cb90 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 261/431] 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 74c2340af9..a975d58073 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 6b687c749d..55d63f13ba 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 262/431] 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 a4c69a8ff3..c3fb1325dc 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 -WORKDIR /root/zephyrproject -RUN west update +# init the west workspace with a minimal manifest +RUN west init -l -WORKDIR /root/zephyrproject/zephyr -RUN west zephyr-export && pip install --no-cache-dir -r ~/zephyrproject/zephyr/scripts/requirements.txt +WORKDIR /root/zephyrproject +RUN west update --stats -# Git clone wamr -WORKDIR /root -RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git +WORKDIR /root/zephyrproject/modules/zephyr +RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt -WORKDIR /root/wasm-micro-runtime/product-mini/platforms/zephyr/simple +ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr" -ENV ZEPHYR_BASE="/root/zephyrproject/zephyr" +# Git clone wamr +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 aab096b8c4..3f1a74c6b9 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 0000000000..447affdb47 --- /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 263/431] 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 05368b9295..39ce5fd034 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 7fefa999d5..2cd300497b 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 82292335bb..e8a084c143 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 ec00602817..6e9153b248 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 264/431] 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 5a8136ca9f..7e25428fcd 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 bacae99ad9..bb56f72fb2 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 265/431] 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 7e25428fcd..0d62ce80d2 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 266/431] 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 db0200cac6..44c8d5168c 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 92b8f55192..d9841a2b39 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 267/431] 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 4a238e65eb..35b2d9bf01 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 0d62ce80d2..dd6b8f14a1 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 268/431] 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 724485449f..1a8ad03c6e 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 269/431] 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 665c1588d5..37d331189b 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 d9e10a71ce..fe105b246f 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 270/431] 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 1172d0a773..f573d35b8d 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; \ From c4623e2cb53b459d646d359403c59345c5dc08e0 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 12 Jun 2025 08:44:45 +0800 Subject: [PATCH 271/431] Enable aot memory64 sw bounds checks by default (#4350) - enable aot memory64 sw bounds checks by default --- core/iwasm/compilation/aot_llvm.c | 15 +++++++++++++++ wamr-compiler/main.c | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index c1708e3f9d..7cbb4a57e3 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -3204,6 +3204,21 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) #if WASM_ENABLE_WAMR_COMPILER != 0 WASMModule *wasm_module = (WASMModule *)comp_data->wasm_module; + bool is_memory64 = false; + + /* TODO: multi-memories for now assuming the memory64 flag of a memory is + * consistent across multi-memories */ + if (wasm_module->import_memory_count > 0) + is_memory64 = !!(wasm_module->import_memories[0].u.memory.mem_type.flags + & MEMORY64_FLAG); + else if (wasm_module->memory_count > 0) + is_memory64 = !!(wasm_module->memories[0].flags & MEMORY64_FLAG); + + if (!(option->bounds_checks == 1 || option->bounds_checks == 0) + && is_memory64) { + /* For memory64, the boundary check default value is true */ + comp_ctx->enable_bound_check = true; + } /* Return error if SIMD is disabled by command line but SIMD instructions * are used */ diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c index f74b2fb151..c9c4ac5da3 100644 --- a/wamr-compiler/main.c +++ b/wamr-compiler/main.c @@ -137,9 +137,12 @@ print_help() printf(" 3 - Small code model\n"); printf(" -sgx Generate code for SGX platform (Intel Software Guard Extensions)\n"); printf(" --bounds-checks=1/0 Enable or disable the bounds checks for memory access:\n"); - printf(" by default it is disabled in all 64-bit platforms except SGX and\n"); - printf(" in these platforms runtime does bounds checks with hardware trap,\n"); - printf(" and by default it is enabled in all 32-bit platforms\n"); + printf(" This flag controls bounds checking with a software check. \n"); + printf(" On 64-bit platforms, it is disabled by default, using a hardware \n"); + printf(" trap if supported, except when SGX or memory64 is enabled,\n"); + printf(" which defaults to a software check.\n"); + printf(" On 32-bit platforms, the flag is enabled by default, using a software check\n"); + printf(" due to the lack of hardware support.\n"); printf(" CAVEAT: --bounds-checks=0 enables some optimizations\n"); printf(" which make the compiled AOT module incompatible\n"); printf(" with a runtime without the hardware bounds checks.\n"); From d52f083ac028d803c6cd57fc2af2f39c18ef3d37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Jun 2025 09:29:33 +0800 Subject: [PATCH 272/431] build(deps): Bump requests from 2.32.3 to 2.32.4 in /build-scripts (#4349) Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.32.3...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build-scripts/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-scripts/requirements.txt b/build-scripts/requirements.txt index ef487e06e0..480d0c4bbf 100644 --- a/build-scripts/requirements.txt +++ b/build-scripts/requirements.txt @@ -1 +1 @@ -requests==2.32.3 \ No newline at end of file +requests==2.32.4 \ No newline at end of file From c93259705724aca99d44960e8b5f9b8c7c01e079 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:29:59 +0900 Subject: [PATCH 273/431] wasi_nn_types.h: remove a seemingly stale comment (#4348) --- core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h | 2 -- 1 file changed, 2 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 dd6b8f14a1..c66e781a72 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -134,8 +134,6 @@ typedef enum execution_target { cpu = 0, gpu, tpu } execution_target; // Bind a `graph` to the input and output tensors for an inference. typedef uint32_t graph_execution_context; -/* Definition of 'wasi_nn.h' structs in WASM app format (using offset) */ - #ifdef __cplusplus } #endif From 928598f1ce9157360e30ebe9522d04e82266453e Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Thu, 12 Jun 2025 09:31:17 +0800 Subject: [PATCH 274/431] add heap-type check for GC when ref.null (#4300) - According to [Link 1](https://webassembly.github.io/gc/core/valid/instructions.html#xref-syntax-instructions-syntax-instr-ref-mathsf-ref-null-mathit-ht), we must ensure that the heap type is valid when ref.null. - According to [Link 2](https://webassembly.github.io/gc/core/valid/types.html#heap-types), a heap type is considered valid if it is either a concrete heap type or an abstract heap type. However, in this function, the check for abstract heap types (absheaptype) was clearly missing, so this condition needs to be added explicitly in the if statement. - When GC is disabled, no change is needed. - When GC is enabled, heap types in WAMR are LEB-encoded values ([Link 3](https://webassembly.github.io/gc/core/appendix/index-types.html)). Therefore, we must use read_leb_int32 to parse the heap type correctly. And we can compute the original type1 using type1 = (uint8)((int32)0x80 + heap_type);. --- core/iwasm/interpreter/wasm_loader.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 6317badc55..cb0414665e 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -831,19 +831,24 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, { uint8 type1; +#if WASM_ENABLE_GC == 0 CHECK_BUF(p, p_end, 1); type1 = read_uint8(p); -#if WASM_ENABLE_GC == 0 cur_value.ref_index = NULL_REF; if (!push_const_expr_stack(&const_expr_ctx, flag, type1, &cur_value, error_buf, error_buf_size)) goto fail; #else + int32 heap_type; + read_leb_int32(p, p_end, heap_type); + type1 = (uint8)((int32)0x80 + heap_type); + cur_value.gc_obj = NULL_REF; if (!is_byte_a_type(type1) + || !wasm_is_valid_heap_type(heap_type) || wasm_is_type_multi_byte_type(type1)) { p--; read_leb_uint32(p, p_end, type_idx); From 3a087c4244aec1a50d06949d3b4f4211dc71f82e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:33:25 +0900 Subject: [PATCH 275/431] wamr-wasi-extensions: add a cmake package to provide our wasi extension (#4344) * wasi_ephemeral_nn.h: add a convenience wrapper header * wamr-wasi-extensions: add a cmake package to provide our wasi extension the sample app was tested with: * wasmtime * iwasm with https://github.com/bytecodealliance/wasm-micro-runtime/pull/4308 currently only contains wasi-nn. maybe it makes sense to add lib-socket things as well. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4288 --- .../wasi-nn/include/wasi_ephemeral_nn.h | 7 + wamr-wasi-extensions/CMakeLists.txt | 8 + wamr-wasi-extensions/nn/CMakeLists.txt | 25 +++ .../samples/nn/CMakeLists.txt | 13 ++ wamr-wasi-extensions/samples/nn/app.c | 169 ++++++++++++++++++ wamr-wasi-extensions/test.sh | 19 ++ 6 files changed, 241 insertions(+) create mode 100644 core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h create mode 100644 wamr-wasi-extensions/CMakeLists.txt create mode 100644 wamr-wasi-extensions/nn/CMakeLists.txt create mode 100644 wamr-wasi-extensions/samples/nn/CMakeLists.txt create mode 100644 wamr-wasi-extensions/samples/nn/app.c create mode 100755 wamr-wasi-extensions/test.sh diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h new file mode 100644 index 0000000000..6a4901afc5 --- /dev/null +++ b/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h @@ -0,0 +1,7 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#define WASM_ENABLE_WASI_EPHEMERAL_NN 1 +#include "wasi_nn.h" diff --git a/wamr-wasi-extensions/CMakeLists.txt b/wamr-wasi-extensions/CMakeLists.txt new file mode 100644 index 0000000000..e5fabb674b --- /dev/null +++ b/wamr-wasi-extensions/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required (VERSION 3.14) + +project(wamr-wasi-extensions LANGUAGES C) + +add_subdirectory(nn) diff --git a/wamr-wasi-extensions/nn/CMakeLists.txt b/wamr-wasi-extensions/nn/CMakeLists.txt new file mode 100644 index 0000000000..27c22c4b88 --- /dev/null +++ b/wamr-wasi-extensions/nn/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_library(wamr-wasi-nn INTERFACE) + +set(wasi_nn_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../core/iwasm/libraries/wasi-nn/include) + +set(headers + ${wasi_nn_header_dir}/wasi_ephemeral_nn.h + ${wasi_nn_header_dir}/wasi_nn.h + ${wasi_nn_header_dir}/wasi_nn_types.h +) + +set_property(TARGET wamr-wasi-nn PROPERTY PUBLIC_HEADER ${headers}) + +target_include_directories(wamr-wasi-nn + INTERFACE + $ + $) + +install(TARGETS wamr-wasi-nn + EXPORT wamr-wasi-nn-config + PUBLIC_HEADER DESTINATION include/wamr) +install(EXPORT wamr-wasi-nn-config + DESTINATION lib/cmake/wamr-wasi-nn) diff --git a/wamr-wasi-extensions/samples/nn/CMakeLists.txt b/wamr-wasi-extensions/samples/nn/CMakeLists.txt new file mode 100644 index 0000000000..59d607f643 --- /dev/null +++ b/wamr-wasi-extensions/samples/nn/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED YES) +set(CMAKE_C_EXTENSIONS NO) + +project(nn-classification-openvino LANGUAGES C) +add_executable(nn-classification-openvino "app.c") +find_package(wamr-wasi-nn REQUIRED) +target_link_libraries(nn-classification-openvino wamr-wasi-nn) diff --git a/wamr-wasi-extensions/samples/nn/app.c b/wamr-wasi-extensions/samples/nn/app.c new file mode 100644 index 0000000000..045d1bd4bb --- /dev/null +++ b/wamr-wasi-extensions/samples/nn/app.c @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * what this application does is basically same as: + * https://github.com/bytecodealliance/wasmtime/tree/efa236e58d09570baaf27865da33fb852fcf40a5/crates/wasi-nn/examples/classification-example + * + * map_file/unmap_file are copy-and-pasted from: + * https://github.com/yamt/toywasm/blob/0eaad8cacd0cc7692946ff19b25994f106113be8/lib/fileio.c + */ + +int +map_file(const char *path, void **pp, size_t *sizep) +{ + void *p; + size_t size; + ssize_t ssz; + int fd; + int ret; + + fd = open(path, O_RDONLY); + if (fd == -1) { + ret = errno; + assert(ret != 0); + return ret; + } + struct stat st; + ret = fstat(fd, &st); + if (ret == -1) { + ret = errno; + assert(ret != 0); + close(fd); + return ret; + } + size = st.st_size; + if (size > 0) { + p = malloc(size); + } + else { + /* Avoid a confusing error */ + p = malloc(1); + } + if (p == NULL) { + close(fd); + return ENOMEM; + } + ssz = read(fd, p, size); + if (ssz != size) { + ret = errno; + assert(ret != 0); + close(fd); + return ret; + } + close(fd); + *pp = p; + *sizep = size; + return 0; +} + +void +unmap_file(void *p, size_t sz) +{ + free(p); +} + +static void +print_result(const float *result, size_t sz) +{ + /* + * just dump the raw result. + * you can postprocess the output with eg. "sort -k2nr | head" + */ + int i; + for (i = 0; i < sz / sizeof(float); i++) { + printf("%d %f\n", i, result[i]); + } +} + +int +main(int argc, char **argv) +{ + wasi_nn_error nnret; + int ret; + void *xml; + size_t xmlsz; + ret = map_file("fixture/model.xml", &xml, &xmlsz); + if (ret != 0) { + fprintf(stderr, "failed to load fixture/model.xml: %s\n", + strerror(ret)); + exit(1); + } + void *weights; + size_t weightssz; + ret = map_file("fixture/model.bin", &weights, &weightssz); + if (ret != 0) { + fprintf(stderr, "failed to load fixture/model.bin: %s\n", + strerror(ret)); + exit(1); + } + /* note: openvino takes two buffers, namely IR and weights */ + graph_builder builders[2] = { { + .buf = xml, + .size = xmlsz, + }, + { + .buf = weights, + .size = weightssz, + } }; + graph g; + nnret = load(builders, 2, openvino, cpu, &g); + unmap_file(xml, xmlsz); + unmap_file(weights, weightssz); + if (nnret != success) { + fprintf(stderr, "load failed with %d\n", (int)nnret); + exit(1); + } + graph_execution_context ctx; + nnret = init_execution_context(g, &ctx); + if (nnret != success) { + fprintf(stderr, "init_execution_context failed with %d\n", (int)nnret); + exit(1); + } + void *tensordata; + size_t tensordatasz; + ret = map_file("fixture/tensor.bgr", &tensordata, &tensordatasz); + if (ret != 0) { + fprintf(stderr, "failed to load fixture/tensor.bgr: %s\n", + strerror(ret)); + exit(1); + } + tensor tensor = { + .dimensions = { .buf = (uint32_t[]){1, 3, 224, 224,}, .size = 4, }, + .type = fp32, + .data = tensordata, + }; + nnret = set_input(ctx, 0, &tensor); + unmap_file(tensordata, tensordatasz); + if (nnret != success) { + fprintf(stderr, "set_input failed with %d\n", (int)nnret); + exit(1); + } + nnret = compute(ctx); + if (nnret != success) { + fprintf(stderr, "compute failed with %d\n", (int)nnret); + exit(1); + } + float result[1001]; + uint32_t resultsz; + nnret = get_output(ctx, 0, (void *)result, sizeof(result), &resultsz); + if (nnret != success) { + fprintf(stderr, "get_output failed with %d\n", (int)nnret); + exit(1); + } + print_result(result, resultsz); +} diff --git a/wamr-wasi-extensions/test.sh b/wamr-wasi-extensions/test.sh new file mode 100755 index 0000000000..585a444bda --- /dev/null +++ b/wamr-wasi-extensions/test.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +PREFIX=/tmp/wamr +WASI_SDK=${WASI_SDK:-/opt/wasi-sdk} + +cmake -B build-lib \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_INSTALL_PREFIX=${PREFIX} \ +. +cmake --build build-lib -t install + +cmake -B build-app-nn \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/nn +cmake --build build-app-nn From 5478d267f4e95d1362221f31890fdf87338d0a75 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:34:14 +0900 Subject: [PATCH 276/431] wasi_nn_openvino.c: remove the tensor layout adjustment logic (#4308) the logic in question seems like an attempt to work around some application bugs. my wild guess is that it was for classification-example. cf. https://github.com/bytecodealliance/wasmtime/issues/10867 --- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 16 ---------------- 1 file changed, 16 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 dcfec1ccb8..d6aef67fe3 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -308,17 +308,6 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, if (ret != success) goto fail; - /* NCHW -> NHWC */ - if (wasi_nn_tensor->dimensions->size == 4 || ov_dims[1] == 3) { - /* N */ - /* H */ - ov_dims[1] = ov_dims[2]; - /* W */ - ov_dims[2] = ov_dims[3]; - /* C */ - ov_dims[3] = 3; - } - CHECK_OV_STATUS(ov_shape_create(wasi_nn_tensor->dimensions->size, ov_dims, &input_shape), ret); @@ -354,11 +343,6 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, CHECK_OV_STATUS(ov_preprocess_input_tensor_info_set_from( input_tensor_info, ov_ctx->input_tensor), ret); - /* ! HAS TO BE NHWC. Match previous layout conversion */ - CHECK_OV_STATUS(ov_layout_create("NHWC", &input_layout), ret); - CHECK_OV_STATUS(ov_preprocess_input_tensor_info_set_layout( - input_tensor_info, input_layout), - ret); /* add RESIZE */ CHECK_OV_STATUS(ov_preprocess_input_info_get_preprocess_steps( From 75bf9797a2b2eee8fd9894836e6c28791b278185 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 15:01:42 +0800 Subject: [PATCH 277/431] Update type validation in load_table_import() and load_table() (#4296) Prevent from value type. https://webassembly.github.io/spec/core/valid/types.html#table-types https://webassembly.github.io/gc/core/syntax/types.html#reference-types --- core/iwasm/interpreter/wasm_loader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index cb0414665e..fe045c6ea9 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -2588,7 +2588,8 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end, error_buf_size)) { return false; } - if (wasm_is_reftype_htref_non_nullable(ref_type.ref_type)) { + if (!wasm_is_type_reftype(ref_type.ref_type) + || wasm_is_reftype_htref_non_nullable(ref_type.ref_type)) { set_error_buf(error_buf, error_buf_size, "type mismatch"); return false; } @@ -3114,6 +3115,15 @@ load_table(const uint8 **p_buf, const uint8 *buf_end, WASMModule *module, error_buf_size)) { return false; } + /* + * TODO: add this validator + * `wasm_is_reftype_htref_non_nullable(ref_type.ref_type)` + * after sync up with the latest GC spec + */ + if (!wasm_is_type_reftype(ref_type.ref_type)) { + set_error_buf(error_buf, error_buf_size, "type mismatch"); + return false; + } table->table_type.elem_type = ref_type.ref_type; if (need_ref_type_map) { if (!(table->table_type.elem_ref_type = From 78e68cec83292254808080eac46a8d854a9fe197 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:05:52 +0800 Subject: [PATCH 278/431] Follow #4268 to deprecate wamr_ide-related components (#4341) refer to: Bypass wamr_ide-related components from the release process. (#4268) --- .../compilation_on_android_ubuntu.yml | 120 ------------------ 1 file changed, 120 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 44c8d5168c..abc88c16bf 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -764,123 +764,3 @@ jobs: eval $(opam env) ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }} working-directory: ./tests/wamr-test-suites - - test-wamr-ide: - needs: - [ - build_iwasm - ] - runs-on: ubuntu-22.04 - env: - PYTHON_VERSION: '3.10' - PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz - - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: install dependencies - run: | - rustup target add wasm32-wasip1 - sudo apt update && sudo apt-get install -y lld ninja-build - npm install - working-directory: test-tools/wamr-ide/VSCode-Extension - - - name: code style check - run: | - npm install --save-dev prettier - npm run prettier-format-check - working-directory: test-tools/wamr-ide/VSCode-Extension - - - name: build iwasm with source debugging feature - run: | - mkdir build - cd build - cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1 - make - working-directory: product-mini/platforms/linux - - - name: Cache LLDB - id: cache-lldb - uses: actions/cache@v4 - env: - cache-name: cache-lldb-vscode - with: - path: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux - key: ${{ env.cache-name }}-${{ hashFiles('build-scripts/lldb_wasm.patch') }}-${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} - - - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }} - name: get stand-alone python ubuntu - run: | - wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz - tar -xvf python.tar.gz - working-directory: core/deps - - - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }} - name: download llvm - run: | - wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip - unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip - mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project - working-directory: core/deps - - - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }} - name: apply wamr patch - run: | - git init - git config user.email "action@github.com" - git config user.name "github action" - git apply ../../../build-scripts/lldb_wasm.patch - working-directory: core/deps/llvm-project - - - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }} - name: build lldb ubuntu - run: | - echo "start to build lldb..." - mkdir -p wamr-lldb - cmake -S ./llvm -B build \ - -G Ninja \ - -DCMAKE_INSTALL_PREFIX=../wamr-lldb \ - -DCMAKE_BUILD_TYPE:STRING="Release" \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DLLVM_ENABLE_PROJECTS="clang;lldb" \ - -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \ - -DLLVM_BUILD_BENCHMARKS:BOOL=OFF \ - -DLLVM_BUILD_DOCS:BOOL=OFF \ - -DLLVM_BUILD_EXAMPLES:BOOL=OFF \ - -DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \ - -DLLVM_BUILD_TESTS:BOOL=OFF \ - -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \ - -DLLVM_INCLUDE_DOCS:BOOL=OFF \ - -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \ - -DLLVM_INCLUDE_TESTS:BOOL=OFF \ - -DLLVM_ENABLE_BINDINGS:BOOL=OFF \ - -DLLVM_ENABLE_LIBXML2:BOOL=ON \ - -DLLVM_ENABLE_LLD:BOOL=ON \ - -DLLDB_ENABLE_PYTHON:BOOL=ON \ - -DLLDB_EMBED_PYTHON_HOME=ON \ - -DLLDB_PYTHON_HOME=.. \ - -DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \ - -DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}" - cmake --build build --target lldb install --parallel $(nproc) - working-directory: core/deps/llvm-project - - - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }} - name: copy lldb to extension folder - run: | - mkdir -p bin - mkdir -p lib - cp ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/package.json ./ - cp -r ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/syntaxes/ ./ - cp ../../../../../../core/deps/llvm-project/build/bin/lldb* bin - cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so lib - cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so.* lib - cp -R ../../../../../../core/deps/llvm-project/build/lib/lldb-python lib - cp -R ../../../../../../core/deps/python/lib/python* lib - cp ../../../../../../core/deps/python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 lib - working-directory: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux - - - name: run tests - timeout-minutes: 5 - run: xvfb-run npm run test - working-directory: test-tools/wamr-ide/VSCode-Extension From 9becf65d1ed0a2f0622d0e19ec3a1666ba8e85cf Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:06:33 +0800 Subject: [PATCH 279/431] clean up incompatible running mode checks in test script and ci (#4342) Rearrange the content of do_execute_in_running_mode() in alphabetical order. Add an incompatible check for x86_32. Now, all belows will be bypassed: - jit, fast-jit, multi-tier-jit - memory64 - multi-memory - simd --- .../compilation_on_android_ubuntu.yml | 43 ------------ .github/workflows/nightly_run.yml | 21 ++---- tests/wamr-test-suites/test_wamr.sh | 65 ++++++++++++------- 3 files changed, 46 insertions(+), 83 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index abc88c16bf..0fbb09e7d4 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -618,49 +618,6 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} running_mode: aot test_option: $WAMR_COMPILER_TEST_OPTIONS - exclude: - # incompatible modes and features - # classic-interp doesn't support simd - - running_mode: "classic-interp" - test_option: $SIMD_TEST_OPTIONS - # llvm jit doesn't support multi module - - running_mode: "jit" - test_option: $MULTI_MODULES_TEST_OPTIONS - # fast-jit doesn't support multi module, simd - - running_mode: "fast-jit" - test_option: $MULTI_MODULES_TEST_OPTIONS - - running_mode: "fast-jit" - test_option: $SIMD_TEST_OPTIONS - # multi-tier-jit doesn't support multi module, simd - - running_mode: "multi-tier-jit" - test_option: $MULTI_MODULES_TEST_OPTIONS - - running_mode: "multi-tier-jit" - test_option: $SIMD_TEST_OPTIONS - # fast-jit and multi-tier-jit don't support GC - - running_mode: "fast-jit" - test_option: $GC_TEST_OPTIONS - - running_mode: "multi-tier-jit" - test_option: $GC_TEST_OPTIONS - # fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Memory64 - - running_mode: "fast-interp" - test_option: $MEMORY64_TEST_OPTIONS - - running_mode: "fast-jit" - test_option: $MEMORY64_TEST_OPTIONS - - running_mode: "jit" - 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 - - running_mode: "aot" - test_option: $MULTI_MEMORY_TEST_OPTIONS - - running_mode: "fast-interp" - test_option: $MULTI_MEMORY_TEST_OPTIONS - - running_mode: "fast-jit" - test_option: $MULTI_MEMORY_TEST_OPTIONS - - running_mode: "jit" - test_option: $MULTI_MEMORY_TEST_OPTIONS - - running_mode: "multi-tier-jit" - test_option: $MULTI_MEMORY_TEST_OPTIONS steps: - name: checkout diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index d9841a2b39..da5003ac94 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -617,24 +617,11 @@ jobs: sanitizer: tsan - running_mode: "multi-tier-jit" sanitizer: tsan - # classic-interp and fast-interp don't support simd - - running_mode: "classic-interp" - test_option: $SIMD_TEST_OPTIONS + # simd128.h brings ubsan errors + # like: negation of XXXcannot be represented in type 'long int'; + # cast to an unsigned type to negate this value to itself - 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 - # fast-jit doesn't support multi module, simd - - running_mode: "fast-jit" - test_option: $MULTI_MODULES_TEST_OPTIONS - - running_mode: "fast-jit" - test_option: $SIMD_TEST_OPTIONS - # multi-tier-jit doesn't support multi module, simd - - running_mode: "multi-tier-jit" - test_option: $MULTI_MODULES_TEST_OPTIONS - - running_mode: "multi-tier-jit" - test_option: $SIMD_TEST_OPTIONS + sanitizer: ubsan steps: - name: checkout uses: actions/checkout@v4 diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 57cef635f3..9c9aa9b56c 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -478,9 +478,9 @@ function spec_test() fi # As of version 1.0.36, wabt is still unable to correctly handle the GC proposal. - # + # # $ $ /opt/wabt-1.0.36/bin/wast2json --enable-all ../spec/test/core/br_if.wast - # + # # ../spec/test/core/br_if.wast:670:26: error: unexpected token "null", expected a numeric index or a name (e.g. 12 or $foo). # (func $f (param (ref null $t)) (result funcref) (local.get 0)) # @@ -877,11 +877,23 @@ function do_execute_in_running_mode() { local RUNNING_MODE="$1" - if [[ ${ENABLE_MULTI_MEMORY} -eq 1 ]]; then + # filter out uncompatible running mode based on targeting proposal features + # keep alpha order + + if [[ ${ENABLE_EH} -eq 1 ]]; then + if [[ "${RUNNING_MODE}" != "classic-interp" ]]; then + echo "support exception handling in classic-interp" + return 0; + fi + fi + + if [[ ${ENABLE_GC} -eq 1 ]]; then if [[ "${RUNNING_MODE}" != "classic-interp" \ + && "${RUNNING_MODE}" != "fast-interp" \ + && "${RUNNING_MODE}" != "jit" \ && "${RUNNING_MODE}" != "aot" ]]; then - echo "support multi-memory in classic-interp mode and aot mode" - return 0 + echo "support gc in both interp modes, llvm-jit mode and aot mode" + return 0; fi fi @@ -893,6 +905,13 @@ function do_execute_in_running_mode() fi fi + if [[ ${ENABLE_MULTI_MEMORY} -eq 1 ]]; then + if [[ "${RUNNING_MODE}" != "classic-interp" ]]; then + echo "support multi-memory in classic-interp mode mode" + return 0 + fi + fi + if [[ ${ENABLE_MULTI_MODULE} -eq 1 ]]; then if [[ "${RUNNING_MODE}" != "classic-interp" \ && "${RUNNING_MODE}" != "fast-interp" \ @@ -902,6 +921,14 @@ function do_execute_in_running_mode() fi fi + if [[ ${ENABLE_SIMD} -eq 1 ]]; then + 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 + + # filter out uncompatible running mode based on SGX support if [[ ${SGX_OPT} == "--sgx" ]]; then if [[ "${RUNNING_MODE}" != "classic-interp" \ && "${RUNNING_MODE}" != "fast-interp" \ @@ -912,33 +939,25 @@ function do_execute_in_running_mode() fi fi - if [[ ${ENABLE_SIMD} -eq 1 ]]; then - if [[ "${RUNNING_MODE}" != "jit" && "${RUNNING_MODE}" != "aot" && "${RUNNING_MODE}" != "fast-interp" ]]; then - echo "support simd in llvm-jit, aot and fast-interp mode" + # filter out uncompatible running mode based on architecture + if [[ ${TARGET} == "X86_32" ]]; then + if [[ "${RUNNING_MODE}" == "jit" || "${RUNNING_MODE}" == "fast-jit" || "${RUNNING_MODE}" == "multi-tier-jit" ]]; then + echo "both llvm-jit, fast-jit and multi-tier-jit mode do not support X86_32 target" return 0; fi - fi - if [[ ${TARGET} == "X86_32" ]]; then - if [[ "${RUNNING_MODE}" == "jit" || "${RUNNING_MODE}" == "fast-jit" ]]; then - echo "both llvm-jit mode and fast-jit mode do not support X86_32 target" + if [[ ${ENABLE_MEMORY64} -eq 1 ]]; then + echo "memory64 does not support X86_32 target" return 0; fi - fi - if [[ ${ENABLE_GC} -eq 1 ]]; then - if [[ "${RUNNING_MODE}" != "classic-interp" \ - && "${RUNNING_MODE}" != "fast-interp" \ - && "${RUNNING_MODE}" != "jit" \ - && "${RUNNING_MODE}" != "aot" ]]; then - echo "support gc in both interp modes, llvm-jit mode and aot mode" + if [[ ${ENABLE_MULTI_MEMORY} -eq 1 ]]; then + echo "multi-memory does not support X86_32 target" return 0; fi - fi - if [[ ${ENABLE_EH} -eq 1 ]]; then - if [[ "${RUNNING_MODE}" != "classic-interp" ]]; then - echo "support exception handling in classic-interp" + if [[ ${ENABLE_SIMD} -eq 1 ]]; then + echo "simd does not support X86_32 target" return 0; fi fi From 2fe7105e8d5df0b5b3c0665be3431ba5bcde78e1 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:06:57 +0800 Subject: [PATCH 280/431] Update WABT downloads URL (#4357) Plus, skip unsupported running mode instead quit during wamr compiler test --- .github/workflows/compilation_on_windows.yml | 4 +++ tests/wamr-test-suites/test_wamr.sh | 35 +++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/compilation_on_windows.yml b/.github/workflows/compilation_on_windows.yml index 21f961cb90..7cee2aa400 100644 --- a/.github/workflows/compilation_on_windows.yml +++ b/.github/workflows/compilation_on_windows.yml @@ -172,6 +172,10 @@ jobs: run: ./build.sh working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/ + - name: install wget + shell: bash + run: choco install wget + - name: run tests shell: bash timeout-minutes: 20 diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 9c9aa9b56c..02b0759801 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.37 + # please sync with .github/actions/install-wasi-sdk-wabt/action.yml if [ ${WABT_BINARY_RELEASE} == "YES" ]; then echo "download a binary release and install" local WAT2WASM=${WORK_DIR}/wabt/out/gcc/Release/wat2wasm @@ -370,30 +370,30 @@ function setup_wabt() cosmopolitan) ;; linux) - WABT_PLATFORM=ubuntu-20.04 + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz + WABT_VERSION=1.0.37 ;; darwin) - WABT_PLATFORM=macos-12 + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz + WABT_VERSION=1.0.36 ;; windows) - WABT_PLATFORM=windows + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz + WABT_VERSION=1.0.37 ;; *) echo "wabt platform for ${PLATFORM} in unknown" exit 1 ;; esac - if [ ! -f /tmp/wabt-${WABT_VERSION}-${WABT_PLATFORM}.tar.gz ]; then - curl -L \ - https://github.com/WebAssembly/wabt/releases/download/${WABT_VERSION}/wabt-${WABT_VERSION}-${WABT_PLATFORM}.tar.gz \ - -o /tmp/wabt-${WABT_VERSION}-${WABT_PLATFORM}.tar.gz - fi - cd /tmp \ - && tar zxf wabt-${WABT_VERSION}-${WABT_PLATFORM}.tar.gz \ - && mkdir -p ${WORK_DIR}/wabt/out/gcc/Release/ \ - && install wabt-${WABT_VERSION}/bin/* ${WORK_DIR}/wabt/out/gcc/Release/ \ - && cd - + pushd /tmp + wget -O wabt-tar.gz --progress=dot:giga ${WABT_URL} + tar xf wabt-tar.gz + popd + + mkdir -p ${WORK_DIR}/wabt/out/gcc/Release/ + cp /tmp/wabt-${WABT_VERSION}/bin/* ${WORK_DIR}/wabt/out/gcc/Release/ fi else echo "download source code and compile and install" @@ -536,6 +536,9 @@ function spec_test() popd echo $(pwd) + #TODO: remove it when we can assume wabt is installed + # especially for CI Or there is installation script in the project + # that we can rely on setup_wabt ln -sf ${WORK_DIR}/../spec-test-script/all.py . @@ -622,8 +625,8 @@ function spec_test() function wamr_compiler_test() { if [[ $1 != "aot" ]]; then - echo "WAMR compiler tests only support AOT mode" - exit 1 + echo "WAMR compiler tests only support AOT mode, skip $1" + return 0 fi echo "Now start WAMR compiler tests" From 0343aaf8c375db1f6b9ae0e6bd1baafbbebc7630 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:57:11 +0800 Subject: [PATCH 281/431] Modify AOT static PGO to conform to llvm-18 and add a CI job to test static PGO on the coremark benchmark (#4345) * static PGO compatible with llvm18 and add CI job to test static PGO on coremark benchmark * update comments and warning info, bitmaps section in llvm profdata shouldn't be used in PGO --- core/iwasm/aot/aot_loader.c | 2 +- core/iwasm/aot/aot_runtime.c | 15 ++++++++++++--- core/iwasm/aot/aot_runtime.h | 10 ++++++++++ core/iwasm/compilation/aot_emit_aot_file.c | 6 ++++++ tests/benchmarks/README.md | 9 +++++++-- tests/benchmarks/coremark/run.sh | 1 + tests/benchmarks/coremark/test_pgo.sh | 1 + 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index b875ab93c5..84bdd0dda3 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -3323,7 +3323,7 @@ do_data_relocation(AOTModule *module, AOTRelocationGroup *group, uint8 *data_addr; uint32 data_size = 0, i; AOTRelocation *relocation = group->relocations; - void *symbol_addr; + void *symbol_addr = NULL; char *symbol, *data_section_name; if (!strncmp(group->section_name, ".rela.", 6)) { diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index b2c9ed6281..c5e1431897 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4877,8 +4877,8 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf, } prof_header.magic = 0xFF6C70726F667281LL; - /* Version 8 */ - prof_header.version = 0x0000000000000008LL; + /* Version 9 */ + prof_header.version = 0x0000000000000009LL; /* with VARIANT_MASK_IR_PROF (IR Instrumentation) */ prof_header.version |= 0x1ULL << 56; /* with VARIANT_MASK_MEMPROF (Memory Profile) */ @@ -4887,14 +4887,19 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf, prof_header.num_prof_counters = num_prof_counters; prof_header.names_size = prof_names_size; prof_header.value_kind_last = 1; + /* __llvm_prf_bits won't be used in PGO, set dummy value here */ + prof_header.num_prof_bitmaps = 0; + prof_header.bitmap_delta = 0; if (!is_little_endian()) { aot_exchange_uint64((uint8 *)&prof_header.magic); aot_exchange_uint64((uint8 *)&prof_header.version); aot_exchange_uint64((uint8 *)&prof_header.num_prof_data); aot_exchange_uint64((uint8 *)&prof_header.num_prof_counters); + aot_exchange_uint64((uint8 *)&prof_header.num_prof_bitmaps); aot_exchange_uint64((uint8 *)&prof_header.names_size); aot_exchange_uint64((uint8 *)&prof_header.counters_delta); + aot_exchange_uint64((uint8 *)&prof_header.bitmap_delta); aot_exchange_uint64((uint8 *)&prof_header.value_kind_last); } @@ -4912,19 +4917,23 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf, prof_data_64->func_md5 = prof_data->func_md5; prof_data_64->func_hash = prof_data->func_hash; prof_data_64->offset_counters = prof_data->offset_counters; + prof_data_64->offset_bitmaps = prof_data->offset_bitmaps; prof_data_64->func_ptr = prof_data->func_ptr; prof_data_64->values = (uint64)(uintptr_t)prof_data->values; prof_data_64->num_counters = prof_data->num_counters; + /* __llvm_prf_bits won't be used in PGO, set dummy value here */ + prof_data_64->num_bitmaps = 0; prof_data_64->num_value_sites[0] = prof_data->num_value_sites[0]; prof_data_64->num_value_sites[1] = prof_data->num_value_sites[1]; if (!is_little_endian()) { aot_exchange_uint64((uint8 *)&prof_data_64->func_hash); aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters); - aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters); + aot_exchange_uint64((uint8 *)&prof_data_64->offset_bitmaps); aot_exchange_uint64((uint8 *)&prof_data_64->func_ptr); aot_exchange_uint64((uint8 *)&prof_data_64->values); aot_exchange_uint32((uint8 *)&prof_data_64->num_counters); + aot_exchange_uint32((uint8 *)&prof_data_64->num_bitmaps); aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[0]); aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[1]); } diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 5be51c05a7..e5678a8d61 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -437,6 +437,9 @@ typedef struct AOTFrame { } AOTFrame; #if WASM_ENABLE_STATIC_PGO != 0 +/* The bitmaps fields in LLVMProfileRawHeader, LLVMProfileData, + * LLVMProfileData_64 all dummy fields, it's used in MC/DC code coverage + * instead of PGO. See https://llvm.org/docs/InstrProfileFormat.html#bitmap */ typedef struct LLVMProfileRawHeader { uint64 magic; uint64 version; @@ -445,8 +448,11 @@ typedef struct LLVMProfileRawHeader { uint64 padding_bytes_before_counters; uint64 num_prof_counters; uint64 padding_bytes_after_counters; + uint64 num_prof_bitmaps; + uint64 padding_bytes_after_bitmaps; uint64 names_size; uint64 counters_delta; + uint64 bitmap_delta; uint64 names_delta; uint64 value_kind_last; } LLVMProfileRawHeader; @@ -464,10 +470,12 @@ typedef struct LLVMProfileData { uint64 func_md5; uint64 func_hash; uint64 offset_counters; + uint64 offset_bitmaps; uintptr_t func_ptr; ValueProfNode **values; uint32 num_counters; uint16 num_value_sites[2]; + uint32 num_bitmaps; } LLVMProfileData; /* The profiling data for writing to the output file, the width of @@ -477,10 +485,12 @@ typedef struct LLVMProfileData_64 { uint64 func_md5; uint64 func_hash; uint64 offset_counters; + uint64 offset_bitmaps; uint64 func_ptr; uint64 values; uint32 num_counters; uint16 num_value_sites[2]; + uint32 num_bitmaps; } LLVMProfileData_64; #endif /* end of WASM_ENABLE_STATIC_PGO != 0 */ diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 097727d132..b41399acb7 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -3378,6 +3378,12 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data) bh_memcpy_s(data_section->name, size, buf, size); data_section->is_name_allocated = true; } + else if (obj_data->comp_ctx->enable_llvm_pgo + && !strcmp(name, "__llvm_prf_bits")) { + LOG_WARNING("__llvm_prf_bits section is not supported and " + "shouldn't be used in PGO."); + return false; + } if (obj_data->comp_ctx->enable_llvm_pgo && !strcmp(name, "__llvm_prf_names")) { diff --git a/tests/benchmarks/README.md b/tests/benchmarks/README.md index 2112829e05..95d85b1c09 100644 --- a/tests/benchmarks/README.md +++ b/tests/benchmarks/README.md @@ -8,6 +8,8 @@ Refer to the `README.md` under each folder for how to build and run the benchmar ## Install `llvm-profdata` +> PS: the `llvm-profdata` vesion needs to be the same major version with llvm libraries used to build wamrc. + The tool `llvm-profdata` is used when running the `test_pgo.sh` script under the benchmark folder. There are two ways to install it: 1. Refer to https://apt.llvm.org/, e.g. in Ubuntu 20.04, add lines below to /etc/apt/source.list @@ -18,19 +20,22 @@ deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main # 15 deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main +# 18 +deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main +deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main ``` Then run `sudo apt update`, `sudo apt install llvm`. And after installing: ```bash cd /usr/bin -sudo ln -s llvm-profdata-15 llvm-profdata +sudo ln -s llvm-profdata-18 llvm-profdata ``` 2. Build manually ```bash -git clone --depth 1 --branch release/15.x https://github.com/llvm/llvm-project.git +git clone --depth 1 --branch release/18.x https://github.com/llvm/llvm-project.git cd llvm-project mkdir build && cd build cmake ../llvm \ diff --git a/tests/benchmarks/coremark/run.sh b/tests/benchmarks/coremark/run.sh index 0d308bb68b..b244863465 100755 --- a/tests/benchmarks/coremark/run.sh +++ b/tests/benchmarks/coremark/run.sh @@ -2,6 +2,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +set -e PLATFORM=$(uname -s | tr A-Z a-z) diff --git a/tests/benchmarks/coremark/test_pgo.sh b/tests/benchmarks/coremark/test_pgo.sh index 1c631312e8..25bed2c451 100755 --- a/tests/benchmarks/coremark/test_pgo.sh +++ b/tests/benchmarks/coremark/test_pgo.sh @@ -2,6 +2,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +set -e PLATFORM=$(uname -s | tr A-Z a-z) From 8e60feb181ec5777b13370b10fdb4cd57d6eec8a Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:26:00 +0800 Subject: [PATCH 282/431] Collective fix for typos and minor bugs (#4369) --- RELEASE_NOTES.md | 2 +- core/iwasm/common/gc/gc_type.c | 2 +- core/iwasm/interpreter/wasm_loader.c | 2 +- core/iwasm/interpreter/wasm_mini_loader.c | 2 +- core/iwasm/libraries/debug-engine/debug_engine.c | 6 +++--- core/shared/platform/esp-idf/espidf_platform.c | 14 ++++++++++++-- language-bindings/python/wamr-api/README.md | 2 +- language-bindings/python/wasm-c-api/docs/design.md | 6 +++--- .../linux-sgx/enclave-sample/App/pal_api.h | 2 +- tests/unit/memory64/memory64_atomic_test.cc | 8 ++++---- 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8b3cfec28b..167da4703f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -497,7 +497,7 @@ - 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 loader and mini-loader select potential 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) diff --git a/core/iwasm/common/gc/gc_type.c b/core/iwasm/common/gc/gc_type.c index bafa3c86c8..8ae12f6424 100644 --- a/core/iwasm/common/gc/gc_type.c +++ b/core/iwasm/common/gc/gc_type.c @@ -1145,7 +1145,7 @@ 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 don't 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) { diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index fe045c6ea9..c8b4e6b7d9 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3712,7 +3712,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, * we shall make a copy of code body [p_code, p_code + code_size] * when we are worrying about inappropriate releasing behaviour. * all code bodies are actually in a buffer which user allocates in - * his embedding environment and we don't have power on them. + * their embedding environment and we don't have power over them. * it will be like: * code_body_cp = malloc(code_size); * memcpy(code_body_cp, p_code, code_size); diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index e66c08bab6..7ff1078c3a 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -1226,7 +1226,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, * we shall make a copy of code body [p_code, p_code + code_size] * when we are worrying about inappropriate releasing behaviour. * all code bodies are actually in a buffer which user allocates in - * his embedding environment and we don't have power on them. + * their embedding environment and we don't have power over them. * it will be like: * code_body_cp = malloc(code_size); * memcpy(code_body_cp, p_code, code_size); diff --git a/core/iwasm/libraries/debug-engine/debug_engine.c b/core/iwasm/libraries/debug-engine/debug_engine.c index 340e657e8b..24d57d7068 100644 --- a/core/iwasm/libraries/debug-engine/debug_engine.c +++ b/core/iwasm/libraries/debug-engine/debug_engine.c @@ -743,7 +743,7 @@ wasm_debug_instance_get_obj_mem(WASMDebugInstance *instance, uint64 offset, module_inst = (WASMModuleInstance *)exec_env->module_inst; if (offset + *size > module_inst->module->load_size) { - LOG_VERBOSE("wasm_debug_instance_get_data_mem size over flow!\n"); + LOG_VERBOSE("wasm_debug_instance_get_data_mem size overflow!\n"); *size = module_inst->module->load_size >= offset ? module_inst->module->load_size - offset : 0; @@ -797,7 +797,7 @@ wasm_debug_instance_get_linear_mem(WASMDebugInstance *instance, uint64 offset, num_bytes_per_page = memory->num_bytes_per_page; linear_mem_size = num_bytes_per_page * memory->cur_page_count; if (offset + *size > linear_mem_size) { - LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n"); + LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n"); *size = linear_mem_size >= offset ? linear_mem_size - offset : 0; } bh_memcpy_s(buf, (uint32)*size, memory->memory_data + offset, @@ -830,7 +830,7 @@ wasm_debug_instance_set_linear_mem(WASMDebugInstance *instance, uint64 offset, num_bytes_per_page = memory->num_bytes_per_page; linear_mem_size = num_bytes_per_page * memory->cur_page_count; if (offset + *size > linear_mem_size) { - LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n"); + LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n"); *size = linear_mem_size >= offset ? linear_mem_size - offset : 0; } bh_memcpy_s(memory->memory_data + offset, (uint32)*size, buf, diff --git a/core/shared/platform/esp-idf/espidf_platform.c b/core/shared/platform/esp-idf/espidf_platform.c index d5f821d074..045c3a5f6d 100644 --- a/core/shared/platform/esp-idf/espidf_platform.c +++ b/core/shared/platform/esp-idf/espidf_platform.c @@ -201,10 +201,20 @@ openat(int fd, const char *pathname, int flags, ...) int ret; char dir_path[DIR_PATH_LEN]; char *full_path; + mode_t mode = 0; + bool has_mode = false; + + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = (mode_t)va_arg(ap, int); + va_end(ap); + has_mode = true; + } ret = fcntl(fd, F_GETPATH, dir_path); if (ret != 0) { - errno = -EINVAL; + errno = EINVAL; return -1; } @@ -214,7 +224,7 @@ openat(int fd, const char *pathname, int flags, ...) return -1; } - new_fd = open(full_path, flags); + new_fd = has_mode ? open(full_path, flags, mode) : open(full_path, flags); free(full_path); return new_fd; diff --git a/language-bindings/python/wamr-api/README.md b/language-bindings/python/wamr-api/README.md index b2ef1e1051..58229da42c 100644 --- a/language-bindings/python/wamr-api/README.md +++ b/language-bindings/python/wamr-api/README.md @@ -6,7 +6,7 @@ ### 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: +Before proceeding it is necessary to make sure your Python environment is correctly configured. To do this open a terminal session in this directory and perform the following: ```shell diff --git a/language-bindings/python/wasm-c-api/docs/design.md b/language-bindings/python/wasm-c-api/docs/design.md index a952731d2d..3478ad021c 100644 --- a/language-bindings/python/wasm-c-api/docs/design.md +++ b/language-bindings/python/wasm-c-api/docs/design.md @@ -353,12 +353,12 @@ writable and needs to be copied into a ctype array. #### variable arguments -A function with _variable arugments_ makes it hard to specify the required +A function with _variable arguments_ makes it hard to specify the required argument types for the function prototype. It leaves us one way to call it directly without any arguments type checking. ```python -libc.printf(b"Hello, an int %d, a float %f, a string %s\n", c_int(1), c_doulbe(3.14), "World!") +libc.printf(b"Hello, an int %d, a float %f, a string %s\n", c_int(1), c_double(3.14), "World!") ``` #### Use `c_bool` to represent `wasm_mutability_t ` @@ -373,7 +373,7 @@ libc.printf(b"Hello, an int %d, a float %f, a string %s\n", c_int(1), c_doulbe(3 ### bindgen.py -`bindge.py` is a tool to create WAMR python binding automatically. `binding.py` +`bindgen.py` is a tool to create WAMR python binding automatically. `binding.py` is generated. We should avoid modification on it. Additional helpers should go to `ffi.py`. 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 2db1fbb252..9b8077c04f 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 @@ -79,7 +79,7 @@ struct wamr_pal_create_process_args { // Untrusted environment variable array pass to new process. // // The untrusted env vars to the command. And the last element of the array - // must be NULL to indicate the length of array. + // must be NULL to indicate the end of the array. // // Optional field. const char **env; diff --git a/tests/unit/memory64/memory64_atomic_test.cc b/tests/unit/memory64/memory64_atomic_test.cc index 2f97038905..49295668d4 100644 --- a/tests/unit/memory64/memory64_atomic_test.cc +++ b/tests/unit/memory64/memory64_atomic_test.cc @@ -60,7 +60,7 @@ class memory64_atomic_test_suite : public testing::TestWithParam return false; } - void destory_exec_env() + void destroy_exec_env() { wasm_runtime_destroy_exec_env(exec_env); wasm_runtime_deinstantiate(module_inst); @@ -109,7 +109,7 @@ class memory64_atomic_test_suite : public testing::TestWithParam virtual void TearDown() { if (cleanup) { - destory_exec_env(); + destroy_exec_env(); wasm_runtime_destroy(); cleanup = false; } @@ -339,8 +339,8 @@ TEST_P(memory64_atomic_test_suite, atomic_opcodes_i64_rmw_cmpxchg) PUT_I64_TO_ADDR(wasm_argv + 2, 0x100F0E0D0C0B0A09); // new PUT_I64_TO_ADDR(wasm_argv + 4, 0xdeadcafebeefdead); - ASSERT_TRUE(wasm_runtime_call_wasm(exec_env, func_map["i64_atomic_rmw_cmpxchg"], - 6, wasm_argv)); + ASSERT_TRUE(wasm_runtime_call_wasm( + exec_env, func_map["i64_atomic_rmw_cmpxchg"], 6, wasm_argv)); i64 = 0x100F0E0D0C0B0A09; ASSERT_EQ(i64, GET_U64_FROM_ADDR(wasm_argv)); From 0d001c4c38422e78a8b771ea0991c1880cd39182 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:01:07 +0900 Subject: [PATCH 283/431] wasi-nn: fix backend leak on multiple loads (#4366) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4340 --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 89 ++++++++++--------- .../libraries/wasi-nn/src/wasi_nn_private.h | 1 + 2 files changed, 50 insertions(+), 40 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 1a8ad03c6e..76cdf1b83e 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -397,6 +397,43 @@ detect_and_load_backend(graph_encoding backend_hint, return ret; } +static wasi_nn_error +ensure_backend(wasm_module_inst_t instance, graph_encoding encoding, + WASINNContext **wasi_nn_ctx_ptr) +{ + wasi_nn_error res; + + graph_encoding loaded_backend = autodetect; + if (!detect_and_load_backend(encoding, &loaded_backend)) { + res = invalid_encoding; + NN_ERR_PRINTF("load backend failed"); + goto fail; + } + + WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); + if (wasi_nn_ctx->is_backend_ctx_initialized) { + if (wasi_nn_ctx->backend != loaded_backend) { + res = unsupported_operation; + goto fail; + } + } + else { + wasi_nn_ctx->backend = loaded_backend; + + /* init() the backend */ + call_wasi_nn_func(wasi_nn_ctx->backend, init, res, + &wasi_nn_ctx->backend_ctx); + if (res != success) + goto fail; + + wasi_nn_ctx->is_backend_ctx_initialized = true; + } + *wasi_nn_ctx_ptr = wasi_nn_ctx; + return success; +fail: + return res; +} + /* WASI-NN implementation */ #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 @@ -410,6 +447,8 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, graph_encoding encoding, execution_target target, graph *g) #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ { + wasi_nn_error res; + NN_DBG_PRINTF("[WASI NN] LOAD [encoding=%d, target=%d]...", encoding, target); @@ -417,7 +456,6 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, if (!instance) return runtime_error; - wasi_nn_error res; graph_builder_array builder_native = { 0 }; #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 if (success @@ -438,19 +476,8 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, goto fail; } - graph_encoding loaded_backend = autodetect; - if (!detect_and_load_backend(encoding, &loaded_backend)) { - res = invalid_encoding; - NN_ERR_PRINTF("load backend failed"); - goto fail; - } - - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_ctx->backend = loaded_backend; - - /* init() the backend */ - call_wasi_nn_func(wasi_nn_ctx->backend, init, res, - &wasi_nn_ctx->backend_ctx); + WASINNContext *wasi_nn_ctx; + res = ensure_backend(instance, encoding, &wasi_nn_ctx); if (res != success) goto fail; @@ -473,6 +500,8 @@ wasi_nn_error wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len, graph *g) { + wasi_nn_error res; + wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env); if (!instance) { return runtime_error; @@ -496,19 +525,8 @@ 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, &loaded_backend)) { - NN_ERR_PRINTF("load backend failed"); - return invalid_encoding; - } - - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_ctx->backend = loaded_backend; - - wasi_nn_error res; - /* init() the backend */ - call_wasi_nn_func(wasi_nn_ctx->backend, init, res, - &wasi_nn_ctx->backend_ctx); + WASINNContext *wasi_nn_ctx; + res = ensure_backend(instance, autodetect, &wasi_nn_ctx); if (res != success) return res; @@ -526,6 +544,8 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name, int32_t name_len, char *config, int32_t config_len, graph *g) { + wasi_nn_error res; + wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env); if (!instance) { return runtime_error; @@ -554,19 +574,8 @@ 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, &loaded_backend)) { - NN_ERR_PRINTF("load backend failed"); - return invalid_encoding; - } - - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_ctx->backend = loaded_backend; - - wasi_nn_error res; - /* init() the backend */ - call_wasi_nn_func(wasi_nn_ctx->backend, init, res, - &wasi_nn_ctx->backend_ctx); + WASINNContext *wasi_nn_ctx; + res = ensure_backend(instance, autodetect, &wasi_nn_ctx); if (res != success) return res; 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 bb56f72fb2..fcca310238 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h @@ -10,6 +10,7 @@ #include "wasm_export.h" typedef struct { + bool is_backend_ctx_initialized; bool is_model_loaded; graph_encoding backend; void *backend_ctx; From d7e3e376a91d9df50a932e0f1a4058d5746a69d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 11:01:21 +0800 Subject: [PATCH 284/431] build(deps): Bump github/codeql-action from 3.28.19 to 3.29.0 (#4371) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.19...v3.29.0) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.29.0 dependency-type: direct:production update-type: version-update:semver-minor ... 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 37d331189b..9c33097213 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.19 + uses: github/codeql-action/init@v3.29.0 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.19 + uses: github/codeql-action/analyze@v3.29.0 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.19 + uses: github/codeql-action/upload-sarif@v3.29.0 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 fe105b246f..827b300f1d 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@b1e4dc3db58c9601794e22a9f6d28d45461b9dbf + uses: github/codeql-action/upload-sarif@2847b7f7ab9f48fc49eca90a53fff6007285f399 with: sarif_file: results.sarif From 7bbdbf521275ce1f93db3d05eaba9bce1292a08f Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Tue, 17 Jun 2025 11:01:38 +0800 Subject: [PATCH 285/431] add validation for array type in load_init_expr(GC only) (#4370) --- core/iwasm/aot/aot_loader.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 84bdd0dda3..f274471f35 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1309,6 +1309,13 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, read_uint32(buf, buf_end, type_idx); read_uint32(buf, buf_end, length); + if (type_idx >= module->type_count + || !wasm_type_is_array_type(module->types[type_idx])) { + set_error_buf(error_buf, error_buf_size, + "invalid or non-array type index."); + goto fail; + } + if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { expr->u.array_new_default.type_index = type_idx; expr->u.array_new_default.length = length; From 745da82cd61fd750f80ea80d3f6e93d863369b4b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:02:36 +0900 Subject: [PATCH 286/431] wasi_nn_openvino.c: remove broken xml check (#4365) `xml.buf[xml.size]` check is broken because it accesses past the end of the buffer. anyway, openvino doesn't seem to care the NUL termination. --- core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c | 6 ------ 1 file changed, 6 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 d6aef67fe3..449839bdf2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -225,12 +225,6 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding, graph_builder xml = builder->buf[0]; graph_builder weight = builder->buf[1]; - /* if xml is a String with a model in IR */ - if (!(xml.buf[xml.size] == '\0' && xml.buf[xml.size - 1] != '\0')) { - NN_ERR_PRINTF("Invalid xml string."); - return invalid_argument; - } - /* transfer weight to an ov tensor */ { ov_ctx->weight_data = os_malloc(weight.size); From 05e3a091506f0d6f1df1ae12e3068b9e14e5cd18 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:13:43 +0900 Subject: [PATCH 287/431] wamr-wasi-extensions: add lib-socket things (#4360) --- wamr-wasi-extensions/CMakeLists.txt | 1 + .../samples/socket-nslookup/CMakeLists.txt | 11 ++++++++++ .../samples/socket-tcp-udp/CMakeLists.txt | 10 ++++++++++ wamr-wasi-extensions/socket/CMakeLists.txt | 20 +++++++++++++++++++ wamr-wasi-extensions/test.sh | 14 +++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 wamr-wasi-extensions/samples/socket-nslookup/CMakeLists.txt create mode 100644 wamr-wasi-extensions/samples/socket-tcp-udp/CMakeLists.txt create mode 100644 wamr-wasi-extensions/socket/CMakeLists.txt diff --git a/wamr-wasi-extensions/CMakeLists.txt b/wamr-wasi-extensions/CMakeLists.txt index e5fabb674b..bed9f6780e 100644 --- a/wamr-wasi-extensions/CMakeLists.txt +++ b/wamr-wasi-extensions/CMakeLists.txt @@ -6,3 +6,4 @@ cmake_minimum_required (VERSION 3.14) project(wamr-wasi-extensions LANGUAGES C) add_subdirectory(nn) +add_subdirectory(socket) diff --git a/wamr-wasi-extensions/samples/socket-nslookup/CMakeLists.txt b/wamr-wasi-extensions/samples/socket-nslookup/CMakeLists.txt new file mode 100644 index 0000000000..3c437524aa --- /dev/null +++ b/wamr-wasi-extensions/samples/socket-nslookup/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED YES) +set(CMAKE_C_EXTENSIONS NO) + +project(socket-nslookup LANGUAGES C) +add_executable(socket-nslookup ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/iwasm/libraries/lib-socket/test/nslookup.c) +find_package(wamr-wasi-socket REQUIRED) +target_link_libraries(socket-nslookup wamr-wasi-socket) +target_link_options(socket-nslookup PRIVATE -Wl,--max-memory=262144) diff --git a/wamr-wasi-extensions/samples/socket-tcp-udp/CMakeLists.txt b/wamr-wasi-extensions/samples/socket-tcp-udp/CMakeLists.txt new file mode 100644 index 0000000000..d166094a71 --- /dev/null +++ b/wamr-wasi-extensions/samples/socket-tcp-udp/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED YES) + +project(socket-tcp-udp LANGUAGES C) +add_executable(socket-tcp-udp ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/iwasm/libraries/lib-socket/test/tcp_udp.c) +find_package(wamr-wasi-socket REQUIRED) +target_link_libraries(socket-tcp-udp wamr-wasi-socket) +target_link_options(socket-tcp-udp PRIVATE -Wl,--max-memory=262144) diff --git a/wamr-wasi-extensions/socket/CMakeLists.txt b/wamr-wasi-extensions/socket/CMakeLists.txt new file mode 100644 index 0000000000..0ffdd453b5 --- /dev/null +++ b/wamr-wasi-extensions/socket/CMakeLists.txt @@ -0,0 +1,20 @@ +set(wasi_socket_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../core/iwasm/libraries/lib-socket) +set(wasi_socket_header_dir ${wasi_socket_dir}/inc) + +set(srcs ${wasi_socket_dir}/src/wasi/wasi_socket_ext.c) +set(headers + ${wasi_socket_header_dir}/wasi_socket_ext.h +) + +add_library(wamr-wasi-socket STATIC ${srcs}) +set_property(TARGET wamr-wasi-socket PROPERTY PUBLIC_HEADER ${headers}) +target_include_directories(wamr-wasi-socket + PUBLIC + $ + $) + +install(TARGETS wamr-wasi-socket + EXPORT wamr-wasi-socket-config + PUBLIC_HEADER DESTINATION include) +install(EXPORT wamr-wasi-socket-config + DESTINATION lib/cmake/wamr-wasi-socket) diff --git a/wamr-wasi-extensions/test.sh b/wamr-wasi-extensions/test.sh index 585a444bda..bf3c45b146 100755 --- a/wamr-wasi-extensions/test.sh +++ b/wamr-wasi-extensions/test.sh @@ -3,6 +3,8 @@ # Copyright (C) 2025 Midokura Japan KK. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +set -e + PREFIX=/tmp/wamr WASI_SDK=${WASI_SDK:-/opt/wasi-sdk} @@ -17,3 +19,15 @@ cmake -B build-app-nn \ -DCMAKE_PREFIX_PATH=${PREFIX} \ samples/nn cmake --build build-app-nn + +cmake -B build-app-socket-nslookup \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/socket-nslookup +cmake --build build-app-socket-nslookup + +cmake -B build-app-socket-tcp-udp \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/socket-tcp-udp +cmake --build build-app-socket-tcp-udp From 965f2452c8cb79db76963f7eb4a309006abd950d Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 17 Jun 2025 11:14:10 +0800 Subject: [PATCH 288/431] improve installation steps for wasi-sdk and wabt on Windows (#4359) --- .../actions/install-wasi-sdk-wabt/action.yml | 53 +++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/actions/install-wasi-sdk-wabt/action.yml b/.github/actions/install-wasi-sdk-wabt/action.yml index c872e42522..6b79087c26 100644 --- a/.github/actions/install-wasi-sdk-wabt/action.yml +++ b/.github/actions/install-wasi-sdk-wabt/action.yml @@ -30,14 +30,23 @@ runs: if: ${{ startsWith(inputs.os, 'ubuntu') }} shell: bash run: | + echo "Downloading wasi-sdk for Ubuntu..." 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 + + echo "Extracting wasi-sdk..." sudo tar -xf wasi-sdk.tar.gz sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk + + echo "Downloading wabt for Ubuntu..." 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 + + echo "Extracting wabt..." 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 @@ -45,14 +54,23 @@ runs: if: ${{ inputs.os == 'macos-13' }} shell: bash run: | + echo "Downloading wasi-sdk for macOS-13..." 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 + + echo "Extracting wasi-sdk..." sudo tar -xf wasi-sdk.tar.gz sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk + + echo "Downloading wabt for macOS-13..." 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 + + echo "Extracting wabt..." 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 @@ -60,21 +78,48 @@ runs: if: ${{ inputs.os == 'macos-14' }} shell: bash run: | + echo "Downloading wasi-sdk for macOS-14..." 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 + + echo "Extracting wasi-sdk..." sudo tar -xf wasi-sdk.tar.gz sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk + + echo "Downloading wabt for macOS-14..." 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 + + echo "Extracting wabt..." 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 + shell: bash run: | - echo "::notice::Support for Windows is not implemented yet" - exit 1 + choco install -y wget + + mkdir -p /opt/wasi-sdk + mkdir -p /opt/wabt + + echo "Downloading wasi-sdk for Windows..." + 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-windows.tar.gz + + echo "Extracting wasi-sdk..." + tar --strip-components=1 -xf wasi-sdk.tar.gz -C /opt/wasi-sdk + + echo "Downloading wabt for Windows..." + wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz + + echo "Extracting wabt..." + tar --strip-components=1 -xf wabt.tar.gz -C /opt/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 Windows" From 20be1d33fe1ac1124c767457e57627c9fa2cde5b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:15:01 +0900 Subject: [PATCH 289/431] wasi_ephemeral_nn.h: prefix identfiers to avoid too generic names (#4358) --- .../wasi-nn/include/wasi_ephemeral_nn.h | 5 + .../iwasm/libraries/wasi-nn/include/wasi_nn.h | 54 +++++---- .../libraries/wasi-nn/include/wasi_nn_types.h | 107 ++++++++++++------ wamr-wasi-extensions/samples/nn/app.c | 49 ++++---- 4 files changed, 133 insertions(+), 82 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h index 6a4901afc5..f76295a1ee 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_ephemeral_nn.h @@ -4,4 +4,9 @@ */ #define WASM_ENABLE_WASI_EPHEMERAL_NN 1 +#define WASI_NN_NAME(name) wasi_ephemeral_nn_##name + #include "wasi_nn.h" + +#undef WASM_ENABLE_WASI_EPHEMERAL_NN +#undef WASI_NN_NAME diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index 35b2d9bf01..48ffe12634 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -34,17 +34,22 @@ * @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"); +WASI_NN_ERROR_TYPE +WASI_NN_NAME(load) +(WASI_NN_NAME(graph_builder) * builder, uint32_t builder_len, + WASI_NN_NAME(graph_encoding) encoding, WASI_NN_NAME(execution_target) target, + WASI_NN_NAME(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"); +WASI_NN_ERROR_TYPE +WASI_NN_NAME(load) +(WASI_NN_NAME(graph_builder_array) * builder, + WASI_NN_NAME(graph_encoding) encoding, WASI_NN_NAME(execution_target) target, + WASI_NN_NAME(graph) * g) WASI_NN_IMPORT("load"); #endif -wasi_nn_error -load_by_name(const char *name, uint32_t name_len, graph *g) +WASI_NN_ERROR_TYPE +WASI_NN_NAME(load_by_name) +(const char *name, uint32_t name_len, WASI_NN_NAME(graph) * g) WASI_NN_IMPORT("load_by_name"); /** @@ -59,8 +64,9 @@ load_by_name(const char *name, uint32_t name_len, graph *g) * @param ctx Execution context. * @return wasi_nn_error Execution status. */ -wasi_nn_error -init_execution_context(graph g, graph_execution_context *ctx) +WASI_NN_ERROR_TYPE +WASI_NN_NAME(init_execution_context) +(WASI_NN_NAME(graph) g, WASI_NN_NAME(graph_execution_context) * ctx) WASI_NN_IMPORT("init_execution_context"); /** @@ -71,9 +77,10 @@ init_execution_context(graph g, graph_execution_context *ctx) * @param tensor Input tensor. * @return wasi_nn_error Execution status. */ -wasi_nn_error -set_input(graph_execution_context ctx, uint32_t index, tensor *tensor) - WASI_NN_IMPORT("set_input"); +WASI_NN_ERROR_TYPE +WASI_NN_NAME(set_input) +(WASI_NN_NAME(graph_execution_context) ctx, uint32_t index, + WASI_NN_NAME(tensor) * tensor) WASI_NN_IMPORT("set_input"); /** * @brief Compute the inference on the given inputs. @@ -81,8 +88,9 @@ set_input(graph_execution_context ctx, uint32_t index, tensor *tensor) * @param ctx Execution context. * @return wasi_nn_error Execution status. */ -wasi_nn_error -compute(graph_execution_context ctx) WASI_NN_IMPORT("compute"); +WASI_NN_ERROR_TYPE +WASI_NN_NAME(compute) +(WASI_NN_NAME(graph_execution_context) ctx) WASI_NN_IMPORT("compute"); /** * @brief Extract the outputs after inference. @@ -97,14 +105,16 @@ compute(graph_execution_context ctx) WASI_NN_IMPORT("compute"); * @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"); +WASI_NN_ERROR_TYPE +WASI_NN_NAME(get_output) +(WASI_NN_NAME(graph_execution_context) ctx, uint32_t index, + WASI_NN_NAME(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_ERROR_TYPE +WASI_NN_NAME(get_output) +(graph_execution_context ctx, uint32_t index, + WASI_NN_NAME(tensor_data) output_tensor, uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); #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 c66e781a72..7980197b73 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -13,6 +13,23 @@ extern "C" { #endif +/* our host logic doesn't use any prefix. neither legacy wasi_nn.h does. */ + +#if !defined(__wasm__) || !defined(WASI_NN_NAME) +#define WASI_NN_NAME(name) name +#define WASI_NN_ERROR_NAME(name) name +#define WASI_NN_TYPE_NAME(name) name +#define WASI_NN_ENCODING_NAME(name) name +#define WASI_NN_TARGET_NAME(name) name +#define WASI_NN_ERROR_TYPE wasi_nn_error +#else +#define WASI_NN_ERROR_NAME(name) WASI_NN_NAME(error_##name) +#define WASI_NN_TYPE_NAME(name) WASI_NN_NAME(type_##name) +#define WASI_NN_ENCODING_NAME(name) WASI_NN_NAME(encoding_##name) +#define WASI_NN_TARGET_NAME(name) WASI_NN_NAME(target_##name) +#define WASI_NN_ERROR_TYPE WASI_NN_NAME(error); +#endif + /** * ERRORS * @@ -22,22 +39,22 @@ extern "C" { // https://github.com/WebAssembly/wasi-nn/blob/71320d95b8c6d43f9af7f44e18b1839db85d89b4/wasi-nn.witx#L5-L17 // Error codes returned by functions in this API. typedef enum { - success = 0, - invalid_argument, - invalid_encoding, - missing_memory, - busy, - runtime_error, - unsupported_operation, - too_large, - not_found, + WASI_NN_ERROR_NAME(success) = 0, + WASI_NN_ERROR_NAME(invalid_argument), + WASI_NN_ERROR_NAME(invalid_encoding), + WASI_NN_ERROR_NAME(missing_memory), + WASI_NN_ERROR_NAME(busy), + WASI_NN_ERROR_NAME(runtime_error), + WASI_NN_ERROR_NAME(unsupported_operation), + WASI_NN_ERROR_NAME(too_large), + WASI_NN_ERROR_NAME(not_found), // for WasmEdge-wasi-nn - end_of_sequence = 100, // End of Sequence Found. - context_full = 101, // Context Full. - prompt_tool_long = 102, // Prompt Too Long. - model_not_found = 103, // Model Not Found. -} wasi_nn_error; + WASI_NN_ERROR_NAME(end_of_sequence) = 100, // End of Sequence Found. + WASI_NN_ERROR_NAME(context_full) = 101, // Context Full. + WASI_NN_ERROR_NAME(prompt_tool_long) = 102, // Prompt Too Long. + WASI_NN_ERROR_NAME(model_not_found) = 103, // Model Not Found. +} WASI_NN_ERROR_TYPE; /** * TENSOR @@ -51,15 +68,27 @@ typedef enum { typedef struct { uint32_t *buf; uint32_t size; -} tensor_dimensions; +} WASI_NN_NAME(tensor_dimensions); #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 // sync up with // 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, u8, i32, i64 } tensor_type; +typedef enum { + WASI_NN_TYPE_NAME(fp16) = 0, + WASI_NN_TYPE_NAME(fp32), + WASI_NN_TYPE_NAME(fp64), + WASI_NN_TYPE_NAME(u8), + WASI_NN_TYPE_NAME(i32), + WASI_NN_TYPE_NAME(i64), +} WASI_NN_NAME(tensor_type); #else -typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type; +typedef enum { + WASI_NN_TYPE_NAME(fp16) = 0, + WASI_NN_TYPE_NAME(fp32), + WASI_NN_TYPE_NAME(up8), + WASI_NN_TYPE_NAME(ip32), +} WASI_NN_NAME(tensor_type); #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ // The tensor data. @@ -70,7 +99,7 @@ typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type; // 4-byte f32 elements would have a data array of length 16). Naturally, this // representation requires some knowledge of how to lay out data in // memory--e.g., using row-major ordering--and could perhaps be improved. -typedef uint8_t *tensor_data; +typedef uint8_t *WASI_NN_NAME(tensor_data); // A tensor. typedef struct { @@ -78,16 +107,16 @@ typedef struct { // 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; + WASI_NN_NAME(tensor_dimensions) dimensions; #else - tensor_dimensions *dimensions; + WASI_NN_NAME(tensor_dimensions) * dimensions; #endif // Describe the type of element in the tensor (e.g., f32). uint8_t type; uint8_t _pad[3]; // Contains the tensor data. - tensor_data data; -} tensor; + WASI_NN_NAME(tensor_data) data; +} WASI_NN_NAME(tensor); /** * GRAPH @@ -102,15 +131,15 @@ typedef struct { typedef struct { uint8_t *buf; uint32_t size; -} graph_builder; +} WASI_NN_NAME(graph_builder); typedef struct { - graph_builder *buf; + WASI_NN_NAME(graph_builder) * buf; uint32_t size; -} graph_builder_array; +} WASI_NN_NAME(graph_builder_array); // An execution graph for performing inference (i.e., a model). -typedef uint32_t graph; +typedef uint32_t WASI_NN_NAME(graph); // sync up with // https://github.com/WebAssembly/wasi-nn/blob/main/wit/wasi-nn.wit#L75 @@ -118,21 +147,25 @@ typedef uint32_t graph; // various backends that encode (i.e., serialize) their graph IR with different // formats. typedef enum { - openvino = 0, - onnx, - tensorflow, - pytorch, - tensorflowlite, - ggml, - autodetect, - unknown_backend, -} graph_encoding; + WASI_NN_ENCODING_NAME(openvino) = 0, + WASI_NN_ENCODING_NAME(onnx), + WASI_NN_ENCODING_NAME(tensorflow), + WASI_NN_ENCODING_NAME(pytorch), + WASI_NN_ENCODING_NAME(tensorflowlite), + WASI_NN_ENCODING_NAME(ggml), + WASI_NN_ENCODING_NAME(autodetect), + WASI_NN_ENCODING_NAME(unknown_backend), +} WASI_NN_NAME(graph_encoding); // Define where the graph should be executed. -typedef enum execution_target { cpu = 0, gpu, tpu } execution_target; +typedef enum WASI_NN_NAME(execution_target) { + WASI_NN_TARGET_NAME(cpu) = 0, + WASI_NN_TARGET_NAME(gpu), + WASI_NN_TARGET_NAME(tpu), +} WASI_NN_NAME(execution_target); // Bind a `graph` to the input and output tensors for an inference. -typedef uint32_t graph_execution_context; +typedef uint32_t WASI_NN_NAME(graph_execution_context); #ifdef __cplusplus } diff --git a/wamr-wasi-extensions/samples/nn/app.c b/wamr-wasi-extensions/samples/nn/app.c index 045d1bd4bb..a3e49a6978 100644 --- a/wamr-wasi-extensions/samples/nn/app.c +++ b/wamr-wasi-extensions/samples/nn/app.c @@ -93,7 +93,7 @@ print_result(const float *result, size_t sz) int main(int argc, char **argv) { - wasi_nn_error nnret; + wasi_ephemeral_nn_error nnret; int ret; void *xml; size_t xmlsz; @@ -112,25 +112,27 @@ main(int argc, char **argv) exit(1); } /* note: openvino takes two buffers, namely IR and weights */ - graph_builder builders[2] = { { - .buf = xml, - .size = xmlsz, - }, - { - .buf = weights, - .size = weightssz, - } }; - graph g; - nnret = load(builders, 2, openvino, cpu, &g); + wasi_ephemeral_nn_graph_builder builders[2] = { { + .buf = xml, + .size = xmlsz, + }, + { + .buf = weights, + .size = weightssz, + } }; + wasi_ephemeral_nn_graph g; + nnret = + wasi_ephemeral_nn_load(builders, 2, wasi_ephemeral_nn_encoding_openvino, + wasi_ephemeral_nn_target_cpu, &g); unmap_file(xml, xmlsz); unmap_file(weights, weightssz); - if (nnret != success) { + if (nnret != wasi_ephemeral_nn_error_success) { fprintf(stderr, "load failed with %d\n", (int)nnret); exit(1); } - graph_execution_context ctx; - nnret = init_execution_context(g, &ctx); - if (nnret != success) { + wasi_ephemeral_nn_graph_execution_context ctx; + nnret = wasi_ephemeral_nn_init_execution_context(g, &ctx); + if (nnret != wasi_ephemeral_nn_error_success) { fprintf(stderr, "init_execution_context failed with %d\n", (int)nnret); exit(1); } @@ -142,26 +144,27 @@ main(int argc, char **argv) strerror(ret)); exit(1); } - tensor tensor = { + wasi_ephemeral_nn_tensor tensor = { .dimensions = { .buf = (uint32_t[]){1, 3, 224, 224,}, .size = 4, }, - .type = fp32, + .type = wasi_ephemeral_nn_type_fp32, .data = tensordata, }; - nnret = set_input(ctx, 0, &tensor); + nnret = wasi_ephemeral_nn_set_input(ctx, 0, &tensor); unmap_file(tensordata, tensordatasz); - if (nnret != success) { + if (nnret != wasi_ephemeral_nn_error_success) { fprintf(stderr, "set_input failed with %d\n", (int)nnret); exit(1); } - nnret = compute(ctx); - if (nnret != success) { + nnret = wasi_ephemeral_nn_compute(ctx); + if (nnret != wasi_ephemeral_nn_error_success) { fprintf(stderr, "compute failed with %d\n", (int)nnret); exit(1); } float result[1001]; uint32_t resultsz; - nnret = get_output(ctx, 0, (void *)result, sizeof(result), &resultsz); - if (nnret != success) { + nnret = wasi_ephemeral_nn_get_output(ctx, 0, (void *)result, sizeof(result), + &resultsz); + if (nnret != wasi_ephemeral_nn_error_success) { fprintf(stderr, "get_output failed with %d\n", (int)nnret); exit(1); } From 2f0750a6fe452a3f9bd7bd4b009b59e461eddd1f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:17:00 +0900 Subject: [PATCH 290/431] wasi_nn_openvino.c: add a missing buffer overflow check in get_output (#4353) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4351 --- core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c | 5 +++++ 1 file changed, 5 insertions(+) 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 449839bdf2..cf35591832 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -439,6 +439,11 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret); + if (byte_size > *output_tensor_size) { + ret = too_large; + goto fail; + } + CHECK_OV_STATUS(ov_tensor_data(ov_tensor, &data), ret); memcpy(output_tensor, data, byte_size); From 6dfb410869eb702a425c1ec4c70f010300e2153d Mon Sep 17 00:00:00 2001 From: Su Yihan Date: Tue, 17 Jun 2025 13:00:58 +0800 Subject: [PATCH 291/431] send an empty/error reply from server (#4362) Signed-off-by: Su Yihan --- core/iwasm/libraries/debug-engine/handler.c | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/core/iwasm/libraries/debug-engine/handler.c b/core/iwasm/libraries/debug-engine/handler.c index 743165dd9e..14c7fae6eb 100644 --- a/core/iwasm/libraries/debug-engine/handler.c +++ b/core/iwasm/libraries/debug-engine/handler.c @@ -175,6 +175,19 @@ process_wasm_global(WASMGDBServer *server, char *args) os_mutex_unlock(&tmpbuf_lock); } +/* TODO: let server send an empty/error reply. + Original issue: 4265 + Not tested yet, but it should work. + */ +static void +send_reply(WASMGDBServer *server, const char *err) +{ + if (!err || !*err) + write_packet(server, ""); + else + write_packet(server, err); +} + void handle_general_query(WASMGDBServer *server, char *payload) { @@ -214,6 +227,7 @@ handle_general_query(WASMGDBServer *server, char *payload) if (!args) { LOG_ERROR("payload parse error during handle_general_query"); + send_reply(server, ""); return; } @@ -384,7 +398,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) if (status == 0) { os_mutex_lock(&tmpbuf_lock); (void)snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status); - write_packet(server, tmpbuf); + send_reply(server, tmpbuf); os_mutex_unlock(&tmpbuf_lock); return; } @@ -403,6 +417,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) "T%02" PRIx32 "thread:%" PRIx64 ";name:%s;", gdb_status, (uint64)(uintptr_t)tid, "nobody"); if (len < 0 || len >= MAX_PACKET_SIZE) { + send_reply(server, "E01"); os_mutex_unlock(&tmpbuf_lock); return; } @@ -410,6 +425,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) if (tids_count > 0) { int n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:"); if (n < 0 || n >= MAX_PACKET_SIZE - len) { + send_reply(server, "E01"); os_mutex_unlock(&tmpbuf_lock); return; } @@ -426,6 +442,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) } if (n < 0 || n >= MAX_PACKET_SIZE - len) { + send_reply(server, "E01"); os_mutex_unlock(&tmpbuf_lock); return; } @@ -452,6 +469,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) "thread-pcs:%" PRIx64 ";00:%s;reason:%s;description:", pc, pc_string, "exception"); if (n < 0 || n >= MAX_PACKET_SIZE - len) { + send_reply(server, "E01"); os_mutex_unlock(&tmpbuf_lock); return; } @@ -462,6 +480,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "%02x", exception[i]); if (n < 0 || n >= MAX_PACKET_SIZE - len) { + send_reply(server, "E01"); os_mutex_unlock(&tmpbuf_lock); return; } @@ -592,7 +611,7 @@ handle_get_register(WASMGDBServer *server, char *payload) int32 i = strtol(payload, NULL, 16); if (i != 0) { - write_packet(server, "E01"); + send_reply(server, "E01"); return; } regdata = wasm_debug_instance_get_pc( @@ -748,7 +767,7 @@ handle_add_break(WASMGDBServer *server, char *payload) if ((arg_c = sscanf(payload, "%zx,%" SCNx64 ",%zx", &type, &addr, &length)) != 3) { LOG_ERROR("Unsupported number of add break arguments %d", arg_c); - write_packet(server, ""); + send_reply(server, ""); return; } @@ -783,7 +802,7 @@ handle_remove_break(WASMGDBServer *server, char *payload) if ((arg_c = sscanf(payload, "%zx,%" SCNx64 ",%zx", &type, &addr, &length)) != 3) { LOG_ERROR("Unsupported number of remove break arguments %d", arg_c); - write_packet(server, ""); + send_reply(server, ""); return; } @@ -835,6 +854,7 @@ handle_malloc(WASMGDBServer *server, char *payload) } else { LOG_ERROR("Payload parse error during handle malloc"); + send_reply(server, ""); return; } From c9b8c16088deeec496bc34b7881928eabd59b3c7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 14:01:46 +0900 Subject: [PATCH 292/431] wasi_nn_openvino.c: remove pre/postprocessing and layout assumptions (#4361) as wasi-nn doesn't have these concepts, the best we can do without risking breaking certain applications here is to pass through tensors as they are. this matches wasmtime's behavior. tested with: * wasmtime classification-example (with this change, this example fails on tensor size mismatch instead of implicitly resizing it.) * license-plate-recognition-barrier-0007, a converted version with non-fp32 output. [1] (with this change, this model outputs integers as expected.) [1] https://github.com/openvinotoolkit/open_model_zoo/tree/cd7ebe313b69372763e76b82e5d24935308fece4/models/public/license-plate-recognition-barrier-0007 --- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 83 +------------------ 1 file changed, 2 insertions(+), 81 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 cf35591832..1cd1625d64 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -32,8 +32,6 @@ typedef struct { void *weight_data; ov_tensor_t *weights_tensor; ov_model_t *model; - /* add prepostprocess */ - ov_model_t *new_model; ov_compiled_model_t *compiled_model; ov_infer_request_t *infer_request; ov_tensor_t *input_tensor; @@ -284,16 +282,6 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, ov_shape_t input_shape = { 0 }; int64_t *ov_dims = NULL; - ov_preprocess_prepostprocessor_t *ppp = NULL; - ov_preprocess_input_info_t *input_info = NULL; - ov_preprocess_input_tensor_info_t *input_tensor_info = NULL; - ov_layout_t *input_layout = NULL; - ov_preprocess_preprocess_steps_t *input_process = NULL; - ov_preprocess_input_model_info_t *p_input_model = NULL; - ov_layout_t *model_layout = NULL; - ov_preprocess_output_info_t *output_info = NULL; - ov_preprocess_output_tensor_info_t *output_tensor_info = NULL; - /* wasi_nn_tensor -> ov_tensor */ { ret = uint32_array_to_int64_array(wasi_nn_tensor->dimensions->size, @@ -322,57 +310,8 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, ret); } - /* set preprocess based on wasi_nn_tensor */ - { - CHECK_OV_STATUS( - ov_preprocess_prepostprocessor_create(ov_ctx->model, &ppp), ret); - - /* reuse user' created tensor's info */ - CHECK_OV_STATUS(ov_preprocess_prepostprocessor_get_input_info_by_index( - ppp, index, &input_info), - ret); - CHECK_OV_STATUS(ov_preprocess_input_info_get_tensor_info( - input_info, &input_tensor_info), - ret); - CHECK_OV_STATUS(ov_preprocess_input_tensor_info_set_from( - input_tensor_info, ov_ctx->input_tensor), - ret); - - /* add RESIZE */ - CHECK_OV_STATUS(ov_preprocess_input_info_get_preprocess_steps( - input_info, &input_process), - ret); - CHECK_OV_STATUS( - ov_preprocess_preprocess_steps_resize(input_process, RESIZE_LINEAR), - ret); - - /* input model */ - CHECK_OV_STATUS( - ov_preprocess_input_info_get_model_info(input_info, &p_input_model), - ret); - // TODO: what if not? - CHECK_OV_STATUS(ov_layout_create("NCHW", &model_layout), ret); - CHECK_OV_STATUS(ov_preprocess_input_model_info_set_layout(p_input_model, - model_layout), - ret); - - /* output -> F32(possibility) */ - CHECK_OV_STATUS(ov_preprocess_prepostprocessor_get_output_info_by_index( - ppp, index, &output_info), - ret); - CHECK_OV_STATUS(ov_preprocess_output_info_get_tensor_info( - output_info, &output_tensor_info), - ret); - CHECK_OV_STATUS( - ov_preprocess_output_set_element_type(output_tensor_info, F32), - ret); - - CHECK_OV_STATUS( - ov_preprocess_prepostprocessor_build(ppp, &ov_ctx->new_model), ret); - } - - CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, ov_ctx->new_model, - "CPU", 0, &ov_ctx->compiled_model), + CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, ov_ctx->model, "CPU", 0, + &ov_ctx->compiled_model), ret); CHECK_OV_STATUS(ov_compiled_model_create_infer_request( @@ -389,24 +328,6 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, if (ov_dims) os_free(ov_dims); ov_shape_free(&input_shape); - if (ppp) - ov_preprocess_prepostprocessor_free(ppp); - if (input_info) - ov_preprocess_input_info_free(input_info); - if (input_tensor_info) - ov_preprocess_input_tensor_info_free(input_tensor_info); - if (input_layout) - ov_layout_free(input_layout); - if (input_process) - ov_preprocess_preprocess_steps_free(input_process); - if (p_input_model) - ov_preprocess_input_model_info_free(p_input_model); - if (model_layout) - ov_layout_free(model_layout); - if (output_info) - ov_preprocess_output_info_free(output_info); - if (output_tensor_info) - ov_preprocess_output_tensor_info_free(output_tensor_info); return ret; } From b3ce192e1ac4542000493b5ba8b2647abbe0e61a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:39:34 +0900 Subject: [PATCH 293/431] add nn-cli example (#4373) an example application with flexible cli options which aims to allow us to perform any wasi-nn operations. eg. ``` --load-graph=file=fixture/model.xml,file=fixture/model.bin,id=graph --init-execution-context=graph-id=graph,id=ctx --set-input=file=fixture/tensor.bgr,context-id=ctx,dim=1,dim=3,dim=224,dim=224 --compute=context-id=ctx --get-output=context-id=ctx,file=output.bin ``` --- .../samples/nn-cli/CMakeLists.txt | 12 + wamr-wasi-extensions/samples/nn-cli/fileio.c | 73 +++ wamr-wasi-extensions/samples/nn-cli/fileio.h | 14 + wamr-wasi-extensions/samples/nn-cli/main.c | 496 ++++++++++++++++++ wamr-wasi-extensions/samples/nn-cli/map.c | 58 ++ wamr-wasi-extensions/samples/nn-cli/map.h | 19 + wamr-wasi-extensions/test.sh | 6 + 7 files changed, 678 insertions(+) create mode 100644 wamr-wasi-extensions/samples/nn-cli/CMakeLists.txt create mode 100644 wamr-wasi-extensions/samples/nn-cli/fileio.c create mode 100644 wamr-wasi-extensions/samples/nn-cli/fileio.h create mode 100644 wamr-wasi-extensions/samples/nn-cli/main.c create mode 100644 wamr-wasi-extensions/samples/nn-cli/map.c create mode 100644 wamr-wasi-extensions/samples/nn-cli/map.h diff --git a/wamr-wasi-extensions/samples/nn-cli/CMakeLists.txt b/wamr-wasi-extensions/samples/nn-cli/CMakeLists.txt new file mode 100644 index 0000000000..df90b5ba4a --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED YES) + +project(nn-cli LANGUAGES C) +add_executable(nn-cli main.c fileio.c map.c) +find_package(wamr-wasi-nn REQUIRED) +target_link_libraries(nn-cli wamr-wasi-nn) diff --git a/wamr-wasi-extensions/samples/nn-cli/fileio.c b/wamr-wasi-extensions/samples/nn-cli/fileio.c new file mode 100644 index 0000000000..5d8163ba49 --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/fileio.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * modified copy-and-paste from: + * https://github.com/yamt/toywasm/blob/0eaad8cacd0cc7692946ff19b25994f106113be8/lib/fileio.c + */ + +#include + +#include +#include +#include +#include +#include + +#include "fileio.h" + +int +map_file(const char *path, void **pp, size_t *sizep) +{ + void *p; + size_t size; + ssize_t ssz; + int fd; + int ret; + + fd = open(path, O_RDONLY); + if (fd == -1) { + ret = errno; + assert(ret != 0); + return ret; + } + struct stat st; + ret = fstat(fd, &st); + if (ret == -1) { + ret = errno; + assert(ret != 0); + close(fd); + return ret; + } + size = st.st_size; + if (size > 0) { + p = malloc(size); + } + else { + /* Avoid a confusing error */ + p = malloc(1); + } + if (p == NULL) { + close(fd); + return ENOMEM; + } + ssz = read(fd, p, size); + if (ssz != size) { + ret = errno; + assert(ret != 0); + close(fd); + return ret; + } + close(fd); + *pp = p; + *sizep = size; + return 0; +} + +void +unmap_file(void *p, size_t sz) +{ + free(p); +} diff --git a/wamr-wasi-extensions/samples/nn-cli/fileio.h b/wamr-wasi-extensions/samples/nn-cli/fileio.h new file mode 100644 index 0000000000..e268222bc9 --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/fileio.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * modified copy-and-paste from: + * https://github.com/yamt/toywasm/blob/0eaad8cacd0cc7692946ff19b25994f106113be8/lib/fileio.h + */ + +int +map_file(const char *filename, void **pp, size_t *szp); +void +unmap_file(void *p, size_t sz); diff --git a/wamr-wasi-extensions/samples/nn-cli/main.c b/wamr-wasi-extensions/samples/nn-cli/main.c new file mode 100644 index 0000000000..894ac455ef --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/main.c @@ -0,0 +1,496 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "fileio.h" +#include "map.h" + +static struct map graphs; +static struct map contexts; + +static void +load_graph(char *options) +{ + int target = wasi_ephemeral_nn_target_cpu; + int encoding = wasi_ephemeral_nn_encoding_openvino; + const char *id = "default"; + wasi_ephemeral_nn_graph_builder *builders = NULL; + size_t nbuilders = 0; + enum { + opt_id, + opt_file, + opt_encoding, + opt_target, + }; + static char *const keylistp[] = { + [opt_id] = "id", + [opt_file] = "file", + [opt_encoding] = "encoding", + [opt_target] = "target", + NULL, + }; + while (*options) { + extern char *suboptarg; + char *value; + const char *saved = options; + switch (getsubopt(&options, keylistp, &value)) { + case opt_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + id = value; + break; + case opt_file: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + builders = + realloc(builders, (nbuilders + 1) * sizeof(*builders)); + if (builders == NULL) { + exit(1); + } + wasi_ephemeral_nn_graph_builder *b = &builders[nbuilders++]; + int ret = map_file(value, (void *)&b->buf, (void *)&b->size); + if (ret != 0) { + fprintf(stderr, "map_file \"%s\" failed: %s\n", value, + strerror(ret)); + exit(1); + } + break; + case opt_encoding: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + encoding = atoi(value); + break; + case opt_target: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + target = atoi(value); + break; + case -1: + fprintf(stderr, "unknown subopt %s\n", saved); + exit(2); + } + } + + wasi_ephemeral_nn_error nnret; + wasi_ephemeral_nn_graph g; + nnret = wasi_ephemeral_nn_load(builders, nbuilders, encoding, target, &g); + size_t i; + for (i = 0; i < nbuilders; i++) { + wasi_ephemeral_nn_graph_builder *b = &builders[i]; + unmap_file(b->buf, b->size); + } + if (nnret != wasi_ephemeral_nn_error_success) { + fprintf(stderr, "load failed with %d\n", (int)nnret); + exit(1); + } + map_set(&graphs, id, g); +} + +static void +init_execution_context(char *options) +{ + const char *id = "default"; + const char *graph_id = "default"; + enum { + opt_id, + opt_graph_id, + }; + static char *const keylistp[] = { + [opt_id] = "id", + [opt_graph_id] = "graph-id", + NULL, + }; + while (*options) { + extern char *suboptarg; + char *value; + const char *saved = options; + switch (getsubopt(&options, keylistp, &value)) { + case opt_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + id = value; + break; + case opt_graph_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + graph_id = value; + break; + case -1: + fprintf(stderr, "unknown subopt %s\n", saved); + exit(2); + } + } + + wasi_ephemeral_nn_graph g = map_get(&graphs, graph_id); + wasi_ephemeral_nn_graph_execution_context c; + wasi_ephemeral_nn_error nnret; + nnret = wasi_ephemeral_nn_init_execution_context(g, &c); + if (nnret != wasi_ephemeral_nn_error_success) { + fprintf(stderr, "init_execution_context failed with %d\n", (int)nnret); + exit(1); + } + map_set(&contexts, id, c); +} + +static void +set_input(char *options) +{ + int ret; + const char *context_id = "default"; + uint32_t idx = 0; + wasi_ephemeral_nn_tensor tensor = { + .dimensions = { .buf = NULL, .size = 0, }, + .type = wasi_ephemeral_nn_type_fp32, + .data = NULL, + }; + void *buf = NULL; + size_t sz = 0; + enum { + opt_context_id, + opt_dim, + opt_type, + opt_idx, + opt_file, + }; + static char *const keylistp[] = { + [opt_context_id] = "context-id", + [opt_dim] = "dim", + [opt_type] = "type", + [opt_idx] = "idx", + [opt_file] = "file", + NULL, + }; + while (*options) { + extern char *suboptarg; + char *value; + const char *saved = options; + switch (getsubopt(&options, keylistp, &value)) { + case opt_context_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + context_id = value; + break; + case opt_dim: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + wasi_ephemeral_nn_tensor_dimensions *dims = &tensor.dimensions; + + dims->buf = + realloc(dims->buf, (dims->size + 1) * sizeof(*dims->buf)); + if (dims->buf == NULL) { + exit(1); + } + dims->buf[dims->size++] = atoi(value); + break; + case opt_type: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + tensor.type = atoi(value); + break; + case opt_file: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + if (buf != NULL) { + fprintf(stderr, "duplicated tensor data\n"); + exit(2); + } + ret = map_file(value, &buf, &sz); + if (ret != 0) { + fprintf(stderr, "map_file \"%s\" failed: %s\n", value, + strerror(ret)); + exit(1); + } + break; + case opt_idx: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + idx = atoi(value); + break; + case -1: + fprintf(stderr, "unknown subopt %s\n", saved); + exit(2); + } + } + + if (tensor.dimensions.size == 0) { + fprintf(stderr, "no dimension is given\n"); + exit(2); + } + if (buf == NULL) { + fprintf(stderr, "no tensor is given\n"); + exit(2); + } + + /* + * REVISIT: we can check the tensor size against type/dimensions + * and warn the user if unexpected. + */ + + wasi_ephemeral_nn_error nnret; + wasi_ephemeral_nn_graph_execution_context c = + map_get(&contexts, context_id); + tensor.data = buf; + nnret = wasi_ephemeral_nn_set_input(c, idx, &tensor); + unmap_file(buf, sz); + if (nnret != wasi_ephemeral_nn_error_success) { + fprintf(stderr, "set_input failed with %d\n", (int)nnret); + exit(1); + } +} + +static void +compute(char *options) +{ + const char *context_id = "default"; + enum { + opt_context_id, + }; + static char *const keylistp[] = { + [opt_context_id] = "context-id", + NULL, + }; + while (*options) { + extern char *suboptarg; + char *value; + const char *saved = options; + switch (getsubopt(&options, keylistp, &value)) { + case opt_context_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + context_id = value; + break; + case -1: + fprintf(stderr, "unknown subopt %s\n", saved); + exit(2); + } + } + + wasi_ephemeral_nn_graph_execution_context c = + map_get(&contexts, context_id); + wasi_ephemeral_nn_error nnret; + nnret = wasi_ephemeral_nn_compute(c); + if (nnret != wasi_ephemeral_nn_error_success) { + fprintf(stderr, "compute failed with %d\n", (int)nnret); + exit(1); + } +} + +static void +get_output(char *options) +{ + int ret; + const char *outfile = NULL; + const char *context_id = "default"; + uint32_t idx = 0; + enum { + opt_context_id, + opt_idx, + opt_file, + }; + static char *const keylistp[] = { + [opt_context_id] = "context-id", + [opt_idx] = "idx", + [opt_file] = "file", + NULL, + }; + while (*options) { + extern char *suboptarg; + char *value; + const char *saved = options; + switch (getsubopt(&options, keylistp, &value)) { + case opt_context_id: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + context_id = value; + break; + case opt_file: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + outfile = value; + break; + case opt_idx: + if (value == NULL) { + fprintf(stderr, "no value for %s\n", saved); + exit(2); + } + idx = atoi(value); + break; + case -1: + fprintf(stderr, "unknown subopt %s\n", saved); + exit(2); + } + } + + int outfd = -1; + if (outfile != NULL) { + outfd = open(outfile, O_CREAT | O_TRUNC | O_WRONLY); + if (outfd == -1) { + fprintf(stderr, "failed to open output file \"%s\": %s\n", outfile, + strerror(errno)); + exit(1); + } + } + + wasi_ephemeral_nn_error nnret; + wasi_ephemeral_nn_graph_execution_context c = + map_get(&contexts, context_id); + void *resultbuf = NULL; + size_t resultbufsz = 256; + uint32_t resultsz; +retry: + resultbuf = realloc(resultbuf, resultbufsz); + if (resultbuf == NULL) { + exit(1); + } + nnret = + wasi_ephemeral_nn_get_output(c, 0, resultbuf, resultbufsz, &resultsz); + if (nnret == wasi_ephemeral_nn_error_too_large) { + resultbufsz *= 2; + goto retry; + } + if (nnret != wasi_ephemeral_nn_error_success) { + fprintf(stderr, "get_output failed with %d\n", (int)nnret); + exit(1); + } + if (outfd != -1) { + ssize_t written = write(outfd, resultbuf, resultsz); + if (written == -1) { + fprintf(stderr, "failed to write: %s\n", strerror(errno)); + exit(1); + } + if (written == -1) { + fprintf(stderr, "unexpetecd write length %zu (expected %zu)\n", + written, (size_t)resultsz); + exit(1); + } + ret = close(outfd); + if (ret != 0) { + fprintf(stderr, "failed to close: %s\n", strerror(errno)); + exit(1); + } + } + else { + fprintf(stderr, "WARNING: discarding %zu bytes output\n", + (size_t)resultsz); + } +} + +enum longopt { + opt_load_graph = 0x100, + opt_init_execution_context, + opt_set_input, + opt_compute, + opt_get_output, +}; + +static const struct option longopts[] = { + { + "load-graph", + required_argument, + NULL, + opt_load_graph, + }, + { + "init-execution-context", + optional_argument, + NULL, + opt_init_execution_context, + }, + { + "set-input", + required_argument, + NULL, + opt_set_input, + }, + { + "compute", + optional_argument, + NULL, + opt_compute, + }, + { + "get-output", + optional_argument, + NULL, + opt_get_output, + }, + { + NULL, + 0, + NULL, + 0, + }, +}; + +int +main(int argc, char **argv) +{ + extern char *optarg; + int ch; + int longidx; + while ((ch = getopt_long(argc, argv, "", longopts, &longidx)) != -1) { + switch (ch) { + case opt_load_graph: + load_graph(optarg); + break; + case opt_init_execution_context: + init_execution_context(optarg ? optarg : ""); + break; + case opt_set_input: + set_input(optarg); + break; + case opt_compute: + compute(optarg ? optarg : ""); + break; + case opt_get_output: + get_output(optarg ? optarg : ""); + break; + default: + exit(2); + } + } + exit(0); +} diff --git a/wamr-wasi-extensions/samples/nn-cli/map.c b/wamr-wasi-extensions/samples/nn-cli/map.c new file mode 100644 index 0000000000..3ed8172423 --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/map.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include +#include +#include +#include +#include + +#include "map.h" + +static uintmax_t * +map_find_slot(struct map *m, const char *name) +{ + size_t i; + for (i = 0; i < m->nentries; i++) { + if (!strcmp(m->entries[i].k, name)) { + return &m->entries[i].v; + } + } + return NULL; +} + +static void +map_append(struct map *m, const char *k, uintmax_t v) +{ + m->entries = realloc(m->entries, (m->nentries + 1) * sizeof(*m->entries)); + if (m->entries == NULL) { + exit(1); + } + struct map_entry *e = &m->entries[m->nentries++]; + e->k = k; + e->v = v; +} + +void +map_set(struct map *m, const char *k, uintmax_t v) +{ + uintmax_t *p = map_find_slot(m, k); + if (p != NULL) { + fprintf(stderr, "duplicated id \"%s\"\n", k); + exit(1); + } + map_append(m, k, v); +} + +uintmax_t +map_get(struct map *m, const char *k) +{ + uintmax_t *p = map_find_slot(m, k); + if (p == NULL) { + fprintf(stderr, "id \"%s\" not found\n", k); + exit(1); + } + return *p; +} diff --git a/wamr-wasi-extensions/samples/nn-cli/map.h b/wamr-wasi-extensions/samples/nn-cli/map.h new file mode 100644 index 0000000000..0059293c8c --- /dev/null +++ b/wamr-wasi-extensions/samples/nn-cli/map.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +struct map { + struct map_entry { + const char *k; + uintmax_t v; + } * entries; + size_t nentries; +}; + +void +map_set(struct map *m, const char *k, uintmax_t v); +uintmax_t +map_get(struct map *m, const char *k); diff --git a/wamr-wasi-extensions/test.sh b/wamr-wasi-extensions/test.sh index bf3c45b146..e485cf48c7 100755 --- a/wamr-wasi-extensions/test.sh +++ b/wamr-wasi-extensions/test.sh @@ -20,6 +20,12 @@ cmake -B build-app-nn \ samples/nn cmake --build build-app-nn +cmake -B build-app-nn-cli \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/nn-cli +cmake --build build-app-nn-cli + cmake -B build-app-socket-nslookup \ -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ -DCMAKE_PREFIX_PATH=${PREFIX} \ From 4ebd1bb59764c9adf1dcfa0fc5966b9b19e5912b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:40:23 +0900 Subject: [PATCH 294/431] wasi-nn: apply the shared library hack to darwin as well (#4374) copied from the linux version. i'm a bit skeptical with this workaround though. it might be simpler to prohibit the use of wamr api in these shared libraries. after all, what these libraries do is nothing specific to wasm. --- product-mini/platforms/darwin/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index cd7c8bc88e..8d19942813 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -114,6 +114,12 @@ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set (CMAKE_MACOSX_RPATH True) +# 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 (BUILD_SHARED_LIBS ON) +endif () + set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) From cba90017495b41cb66e33ff10abf6d2e110efbb5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:40:53 +0900 Subject: [PATCH 295/431] wasi-nn: don't try to deinit uninitialized backend (#4375) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4339 --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 8 +++++--- 1 file changed, 5 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 76cdf1b83e..6098ef465e 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -99,9 +99,11 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) NN_DBG_PRINTF("-> current_encoding: %d", wasi_nn_ctx->backend); /* deinit() the backend */ - wasi_nn_error res; - call_wasi_nn_func(wasi_nn_ctx->backend, deinit, res, - wasi_nn_ctx->backend_ctx); + if (wasi_nn_ctx->is_backend_ctx_initialized) { + wasi_nn_error res; + call_wasi_nn_func(wasi_nn_ctx->backend, deinit, res, + wasi_nn_ctx->backend_ctx); + } wasm_runtime_free(wasi_nn_ctx); } From 4bf799c3af68fbbe5cdda61a59ff3d1ebea4ef8b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:06:57 +0900 Subject: [PATCH 296/431] core/iwasm/libraries/wasi-nn/test/build.sh: add a tip for intel mac (#4389) i keep forgetting this and had to re-investigate it at least twice. hopefully this can be helpful for others too. --- core/iwasm/libraries/wasi-nn/test/build.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/iwasm/libraries/wasi-nn/test/build.sh b/core/iwasm/libraries/wasi-nn/test/build.sh index dda400f161..14f6b9e090 100755 --- a/core/iwasm/libraries/wasi-nn/test/build.sh +++ b/core/iwasm/libraries/wasi-nn/test/build.sh @@ -3,6 +3,17 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# on intel mac, this ends up with a lot of the following error. +# +# AttributeError: 'Sequential' object has no attribute '_get_save_spec'. +# +# * "pip install tensorflow" installs tensorflow 2.16.2 on intel mac. +# (because it's the last version before tf deprecated the target.) +# * keras 3 support in the version seems incomplete (thus the error) +# * a workaround: use keras 2 as mentioned in: +# https://github.com/tensorflow/tensorflow/releases/tag/v2.16.1 +# https://blog.tensorflow.org/2024/03/whats-new-in-tensorflow-216.html + CURR_PATH=$(cd $(dirname $0) && pwd -P) # WASM application that uses WASI-NN From db7714f0f5614b567fd6d521191adffcf03b2f59 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:08:57 +0900 Subject: [PATCH 297/431] wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388) this backend assumes fp32 here and there. it's safer to reject unexpected inputs explicitly. --- core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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 09e12f0d2d..9c458179ab 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -281,6 +281,11 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index, { TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx; + if (input_tensor->type != fp32) { + NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type); + return runtime_error; + } + wasi_nn_error res; if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx))) return res; From 8414a20dfeee6764754902ab4fa8bab95fc9a56f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 18 Jun 2025 19:16:47 +0800 Subject: [PATCH 298/431] Fix several issues related to night-run CI and test scripts. (#4385) - remove duplicated options - fix test script - change ci to use binary --- .github/workflows/nightly_run.yml | 11 ++++---- tests/wamr-test-suites/test_wamr.sh | 42 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index da5003ac94..1ae405f60d 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -36,12 +36,11 @@ env: 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" # For Spec Test - # FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04 - DEFAULT_TEST_OPTIONS: "-s spec -P" - MULTI_MODULES_TEST_OPTIONS: "-s spec -M -P" - SIMD_TEST_OPTIONS: "-s spec -S -P" - THREADS_TEST_OPTIONS: "-s spec -p -P" - X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P" + DEFAULT_TEST_OPTIONS: "-s spec -b -P" + MULTI_MODULES_TEST_OPTIONS: "-s spec -b -P -M" + SIMD_TEST_OPTIONS: "-s spec -b -P -S" + THREADS_TEST_OPTIONS: "-s spec -b -P -p" + X86_32_TARGET_TEST_OPTIONS: "-m x86_32" WASI_TEST_OPTIONS: "-s wasi_certification -w" permissions: diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 02b0759801..8a72ae2016 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -362,31 +362,31 @@ function sightglass_test() function setup_wabt() { # please sync with .github/actions/install-wasi-sdk-wabt/action.yml + case ${PLATFORM} in + cosmopolitan) + ;; + linux) + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz + WABT_VERSION=1.0.37 + ;; + darwin) + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz + WABT_VERSION=1.0.36 + ;; + windows) + WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz + WABT_VERSION=1.0.37 + ;; + *) + echo "wabt platform for ${PLATFORM} in unknown" + exit 1 + ;; + esac + if [ ${WABT_BINARY_RELEASE} == "YES" ]; then echo "download a binary release and install" local WAT2WASM=${WORK_DIR}/wabt/out/gcc/Release/wat2wasm if [ ! -f ${WAT2WASM} ]; then - case ${PLATFORM} in - cosmopolitan) - ;; - linux) - WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz - WABT_VERSION=1.0.37 - ;; - darwin) - WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz - WABT_VERSION=1.0.36 - ;; - windows) - WABT_URL=https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz - WABT_VERSION=1.0.37 - ;; - *) - echo "wabt platform for ${PLATFORM} in unknown" - exit 1 - ;; - esac - pushd /tmp wget -O wabt-tar.gz --progress=dot:giga ${WABT_URL} tar xf wabt-tar.gz From a29f3943eff4df40e9e0eaf22aa9faa9f5940e8c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:24:06 +0900 Subject: [PATCH 299/431] core/iwasm/libraries/wasi-nn/test: use the correct version of keras (#4383) --- core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py b/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py index 98a50129cc..8506e18062 100755 --- a/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py +++ b/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py @@ -3,7 +3,7 @@ import tensorflow as tf import numpy as np -from keras.layers import AveragePooling2D, Conv2D +from tensorflow.keras.layers import AveragePooling2D, Conv2D from tensorflow.keras import Input, Model From aa53d648fa327e1f65943a0082317854a6bd6765 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Jun 2025 15:18:36 +0900 Subject: [PATCH 300/431] wasi-nn: fix tensor_data abi for wasi_ephemeral_nn (#4379) it's "(list u8)" in the witx definition. the new definition matches both of our own host definition (struct tensor_wasm) and wasmtime. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4352 --- core/iwasm/libraries/wasi-nn/include/wasi_nn.h | 7 +++---- core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h | 7 +++++++ wamr-wasi-extensions/samples/nn-cli/main.c | 3 ++- wamr-wasi-extensions/samples/nn/app.c | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index 48ffe12634..2f41732447 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -108,14 +108,13 @@ WASI_NN_NAME(compute) WASI_NN_ERROR_TYPE WASI_NN_NAME(get_output) (WASI_NN_NAME(graph_execution_context) ctx, uint32_t index, - WASI_NN_NAME(tensor_data) output_tensor, uint32_t output_tensor_max_size, + uint8_t *output_tensor, uint32_t output_tensor_max_size, uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); #else WASI_NN_ERROR_TYPE WASI_NN_NAME(get_output) -(graph_execution_context ctx, uint32_t index, - WASI_NN_NAME(tensor_data) output_tensor, uint32_t *output_tensor_size) - WASI_NN_IMPORT("get_output"); +(graph_execution_context ctx, uint32_t index, uint8_t *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 7980197b73..d2e3f4caca 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -99,7 +99,14 @@ typedef enum { // 4-byte f32 elements would have a data array of length 16). Naturally, this // representation requires some knowledge of how to lay out data in // memory--e.g., using row-major ordering--and could perhaps be improved. +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 && defined(__wasm__) +typedef struct { + uint8_t *buf; + uint32_t size; +} WASI_NN_NAME(tensor_data); +#else typedef uint8_t *WASI_NN_NAME(tensor_data); +#endif // A tensor. typedef struct { diff --git a/wamr-wasi-extensions/samples/nn-cli/main.c b/wamr-wasi-extensions/samples/nn-cli/main.c index 894ac455ef..0358158f3f 100644 --- a/wamr-wasi-extensions/samples/nn-cli/main.c +++ b/wamr-wasi-extensions/samples/nn-cli/main.c @@ -266,7 +266,8 @@ set_input(char *options) wasi_ephemeral_nn_error nnret; wasi_ephemeral_nn_graph_execution_context c = map_get(&contexts, context_id); - tensor.data = buf; + tensor.data.buf = buf; + tensor.data.size = sz; nnret = wasi_ephemeral_nn_set_input(c, idx, &tensor); unmap_file(buf, sz); if (nnret != wasi_ephemeral_nn_error_success) { diff --git a/wamr-wasi-extensions/samples/nn/app.c b/wamr-wasi-extensions/samples/nn/app.c index a3e49a6978..15f6377326 100644 --- a/wamr-wasi-extensions/samples/nn/app.c +++ b/wamr-wasi-extensions/samples/nn/app.c @@ -147,7 +147,8 @@ main(int argc, char **argv) wasi_ephemeral_nn_tensor tensor = { .dimensions = { .buf = (uint32_t[]){1, 3, 224, 224,}, .size = 4, }, .type = wasi_ephemeral_nn_type_fp32, - .data = tensordata, + .data.buf = tensordata, + .data.size = tensordatasz, }; nnret = wasi_ephemeral_nn_set_input(ctx, 0, &tensor); unmap_file(tensordata, tensordatasz); From e5091e47ea9fb88971418a1de2083ddc34dd3164 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Jun 2025 15:30:44 +0900 Subject: [PATCH 301/431] enable WAMR_BUILD_WASI_EPHEMERAL_NN by default (#4381) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4326 --- build-scripts/config_common.cmake | 3 +++ doc/build_wamr.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 1a77d4cac8..b4013210ab 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -539,6 +539,9 @@ if (WAMR_BUILD_WASI_NN EQUAL 1) if (DEFINED WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH) add_definitions (-DWASM_WASI_NN_EXTERNAL_DELEGATE_PATH="${WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH}") endif () + if (NOT DEFINED WAMR_BUILD_WASI_EPHEMERAL_NN) + set(WAMR_BUILD_WASI_EPHEMERAL_NN 1) + endif() if (WAMR_BUILD_WASI_EPHEMERAL_NN EQUAL 1) message (" WASI-NN: use 'wasi_ephemeral_nn' instead of 'wasi-nn'") add_definitions (-DWASM_ENABLE_WASI_EPHEMERAL_NN=1) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 94dd96284e..0c6623c15c 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -113,7 +113,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM - **WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH**=Path to the external delegate shared library (e.g. `libedgetpu.so.1.0` for Coral USB) ### **Enable lib wasi-nn with `wasi_ephemeral_nn` module support** -- **WAMR_BUILD_WASI_EPHEMERAL_NN**=1/0, default to disable if not set +- **WAMR_BUILD_WASI_EPHEMERAL_NN**=1/0, default to enable if not set ### **Disable boundary check with hardware trap** - **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform From 71c07f3e4ec48dca6ddb7313888a5510675448e0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Jun 2025 15:32:26 +0900 Subject: [PATCH 302/431] deprecate legacy WAMR-specific "wasi_nn" module (#4382) wasi_nn.h: deprecate legacy "wasi_nn" cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4326 --- core/iwasm/libraries/wasi-nn/include/wasi_nn.h | 1 + core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 4 ++++ doc/build_wamr.md | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index 2f41732447..cda26324eb 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -21,6 +21,7 @@ #else #define WASI_NN_IMPORT(name) \ __attribute__((import_module("wasi_nn"), import_name(name))) +#warning You are using "wasi_nn", which is a legacy WAMR-specific ABI. It's deperecated and will likely be removed in future versions of WAMR. Please use "wasi_ephemeral_nn" instead. (For a WASM module, use the wasi_ephemeral_nn.h header instead. For the runtime configurations, enable WASM_ENABLE_WASI_EPHEMERAL_NN/WAMR_BUILD_WASI_EPHEMERAL_NN.) #endif /** diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 6098ef465e..6fc0d07f81 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -20,6 +20,10 @@ #include "wasi_nn_types.h" #include "wasm_export.h" +#if WASM_ENABLE_WASI_EPHEMERAL_NN == 0 +#warning You are using "wasi_nn", which is a legacy WAMR-specific ABI. It's deperecated and will likely be removed in future versions of WAMR. Please use "wasi_ephemeral_nn" instead. (For a WASM module, use the wasi_ephemeral_nn.h header instead. For the runtime configurations, enable WASM_ENABLE_WASI_EPHEMERAL_NN/WAMR_BUILD_WASI_EPHEMERAL_NN.) +#endif + #define HASHMAP_INITIAL_SIZE 20 #if defined(__APPLE__) #define LIB_EXTENTION ".dylib" diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 0c6623c15c..12d9016792 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -102,6 +102,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM ### **Enable lib wasi-nn** - **WAMR_BUILD_WASI_NN**=1/0, default to disable if not set +> Note: WAMR_BUILD_WASI_NN without WAMR_BUILD_WASI_EPHEMERAL_NN is deprecated and will likely be removed in future versions of WAMR. Please consider to enable WAMR_BUILD_WASI_EPHEMERAL_NN as well. > Note: See [WASI-NN](../core/iwasm/libraries/wasi-nn) for more details. ### **Enable lib wasi-nn GPU mode** @@ -360,4 +361,4 @@ For Valgrind, begin with the following configurations and add additional ones as -DWAMR_DISABLE_HW_BOUND_CHECK=0 \ -DWAMR_DISABLE_WRITE_GS_BASE=0 #... -``` \ No newline at end of file +``` From ea408ab6c0438acef61eccefa53fdd059ee8f9f7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 20 Jun 2025 10:48:55 +0900 Subject: [PATCH 303/431] wasi-nn: add minimum serialization on WASINNContext (#4387) currently this is not necessary because context (WASINNContext) is local to instance. (wasm_module_instance_t) i plan to make a context shared among instances in a cluster when fixing https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313. this is a preparation for that direction. an obvious alternative is to tweak the module instance context APIs to allow declaring some kind of contexts instance-local. but i feel, in this particular case, it's more natural to make "wasi-nn handles" shared among threads within a "process". note that, spec-wise, how wasi-nn behaves wrt threads is not defined at all because wasi officially doesn't have threads yet. i suppose, at this point, that how wasi-nn interacts with wasi-threads is something we need to define by ourselves, especially when we are using an outdated wasi-nn version. with this change, if a thread attempts to access a context while another thread is using it, we simply make the operation fail with the "busy" error. this is intended for the mimimum serialization to avoid problems like crashes/leaks/etc. this is not intended to allow parallelism or such. no functional changes are intended at this point yet. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313 https://github.com/bytecodealliance/wasm-micro-runtime/issues/2430 --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 149 ++++++++++++++---- .../libraries/wasi-nn/src/wasi_nn_private.h | 4 + 2 files changed, 120 insertions(+), 33 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 6fc0d07f81..5c916aa4a1 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -102,6 +102,8 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) NN_DBG_PRINTF("-> is_model_loaded: %d", wasi_nn_ctx->is_model_loaded); NN_DBG_PRINTF("-> current_encoding: %d", wasi_nn_ctx->backend); + bh_assert(!wasi_nn_ctx->busy); + /* deinit() the backend */ if (wasi_nn_ctx->is_backend_ctx_initialized) { wasi_nn_error res; @@ -109,6 +111,7 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) wasi_nn_ctx->backend_ctx); } + os_mutex_destroy(&wasi_nn_ctx->lock); wasm_runtime_free(wasi_nn_ctx); } @@ -154,6 +157,11 @@ wasi_nn_initialize_context() } memset(wasi_nn_ctx, 0, sizeof(WASINNContext)); + if (os_mutex_init(&wasi_nn_ctx->lock)) { + NN_ERR_PRINTF("Error when initializing a lock for WASI-NN context"); + wasm_runtime_free(wasi_nn_ctx); + return NULL; + } return wasi_nn_ctx; } @@ -180,6 +188,35 @@ wasm_runtime_get_wasi_nn_ctx(wasm_module_inst_t instance) return wasi_nn_ctx; } +static WASINNContext * +lock_ctx(wasm_module_inst_t instance) +{ + WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); + if (wasi_nn_ctx == NULL) { + return NULL; + } + os_mutex_lock(&wasi_nn_ctx->lock); + if (wasi_nn_ctx->busy) { + os_mutex_unlock(&wasi_nn_ctx->lock); + return NULL; + } + wasi_nn_ctx->busy = true; + os_mutex_unlock(&wasi_nn_ctx->lock); + return wasi_nn_ctx; +} + +static void +unlock_ctx(WASINNContext *wasi_nn_ctx) +{ + if (wasi_nn_ctx == NULL) { + return; + } + os_mutex_lock(&wasi_nn_ctx->lock); + bh_assert(wasi_nn_ctx->busy); + wasi_nn_ctx->busy = false; + os_mutex_unlock(&wasi_nn_ctx->lock); +} + void wasi_nn_destroy() { @@ -405,7 +442,7 @@ detect_and_load_backend(graph_encoding backend_hint, static wasi_nn_error ensure_backend(wasm_module_inst_t instance, graph_encoding encoding, - WASINNContext **wasi_nn_ctx_ptr) + WASINNContext *wasi_nn_ctx) { wasi_nn_error res; @@ -416,7 +453,6 @@ ensure_backend(wasm_module_inst_t instance, graph_encoding encoding, goto fail; } - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); if (wasi_nn_ctx->is_backend_ctx_initialized) { if (wasi_nn_ctx->backend != loaded_backend) { res = unsupported_operation; @@ -434,7 +470,6 @@ ensure_backend(wasm_module_inst_t instance, graph_encoding encoding, wasi_nn_ctx->is_backend_ctx_initialized = true; } - *wasi_nn_ctx_ptr = wasi_nn_ctx; return success; fail: return res; @@ -462,17 +497,23 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, if (!instance) return runtime_error; + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + graph_builder_array builder_native = { 0 }; #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 if (success != (res = graph_builder_array_app_native( instance, builder, builder_wasm_size, &builder_native))) - return res; + goto fail; #else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ if (success != (res = graph_builder_array_app_native(instance, builder, &builder_native))) - return res; + goto fail; #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ if (!wasm_runtime_validate_native_addr(instance, g, @@ -482,8 +523,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, goto fail; } - WASINNContext *wasi_nn_ctx; - res = ensure_backend(instance, encoding, &wasi_nn_ctx); + res = ensure_backend(instance, encoding, wasi_nn_ctx); if (res != success) goto fail; @@ -498,6 +538,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, // XXX: Free intermediate structure pointers if (builder_native.buf) wasm_runtime_free(builder_native.buf); + unlock_ctx(wasi_nn_ctx); return res; } @@ -531,18 +572,26 @@ 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); - WASINNContext *wasi_nn_ctx; - res = ensure_backend(instance, autodetect, &wasi_nn_ctx); + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + + res = ensure_backend(instance, autodetect, wasi_nn_ctx); if (res != success) - return res; + goto fail; call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res, wasi_nn_ctx->backend_ctx, name, name_len, g); if (res != success) - return res; + goto fail; wasi_nn_ctx->is_model_loaded = true; - return success; + res = success; +fail: + unlock_ctx(wasi_nn_ctx); + return res; } wasi_nn_error @@ -580,19 +629,28 @@ 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); - WASINNContext *wasi_nn_ctx; - res = ensure_backend(instance, autodetect, &wasi_nn_ctx); + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + + res = ensure_backend(instance, autodetect, wasi_nn_ctx); if (res != success) - return res; + goto fail; + ; call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res, wasi_nn_ctx->backend_ctx, name, name_len, config, config_len, g); if (res != success) - return res; + goto fail; wasi_nn_ctx->is_model_loaded = true; - return success; + res = success; +fail: + unlock_ctx(wasi_nn_ctx); + return res; } wasi_nn_error @@ -606,20 +664,27 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g, return runtime_error; } - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_error res; + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + if (success != (res = is_model_initialized(wasi_nn_ctx))) - return res; + goto fail; if (!wasm_runtime_validate_native_addr( instance, ctx, (uint64)sizeof(graph_execution_context))) { NN_ERR_PRINTF("ctx is invalid"); - return invalid_argument; + res = invalid_argument; + goto fail; } call_wasi_nn_func(wasi_nn_ctx->backend, init_execution_context, res, wasi_nn_ctx->backend_ctx, g, ctx); +fail: + unlock_ctx(wasi_nn_ctx); return res; } @@ -634,17 +699,21 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx, return runtime_error; } - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_error res; + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + if (success != (res = is_model_initialized(wasi_nn_ctx))) - return res; + goto fail; tensor input_tensor_native = { 0 }; if (success != (res = tensor_app_native(instance, input_tensor, &input_tensor_native))) - return res; + goto fail; call_wasi_nn_func(wasi_nn_ctx->backend, set_input, res, wasi_nn_ctx->backend_ctx, ctx, index, @@ -652,7 +721,8 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx, // XXX: Free intermediate structure pointers if (input_tensor_native.dimensions) wasm_runtime_free(input_tensor_native.dimensions); - +fail: + unlock_ctx(wasi_nn_ctx); return res; } @@ -666,14 +736,20 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx) return runtime_error; } - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_error res; + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + if (success != (res = is_model_initialized(wasi_nn_ctx))) - return res; + goto fail; call_wasi_nn_func(wasi_nn_ctx->backend, compute, res, wasi_nn_ctx->backend_ctx, ctx); +fail: + unlock_ctx(wasi_nn_ctx); return res; } @@ -696,16 +772,21 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, return runtime_error; } - WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); - wasi_nn_error res; + WASINNContext *wasi_nn_ctx = lock_ctx(instance); + if (wasi_nn_ctx == NULL) { + res = busy; + goto fail; + } + if (success != (res = is_model_initialized(wasi_nn_ctx))) - return res; + goto fail; if (!wasm_runtime_validate_native_addr(instance, output_tensor_size, (uint64)sizeof(uint32_t))) { NN_ERR_PRINTF("output_tensor_size is invalid"); - return invalid_argument; + res = invalid_argument; + goto fail; } #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 @@ -718,6 +799,8 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, wasi_nn_ctx->backend_ctx, ctx, index, output_tensor, output_tensor_size); #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ +fail: + unlock_ctx(wasi_nn_ctx); return res; } 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 fcca310238..a20ad1718c 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h @@ -9,7 +9,11 @@ #include "wasi_nn_types.h" #include "wasm_export.h" +#include "bh_platform.h" + typedef struct { + korp_mutex lock; + bool busy; bool is_backend_ctx_initialized; bool is_model_loaded; graph_encoding backend; From 64cafaff1eee1942154867e4c4088dd2bfb70284 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 20 Jun 2025 15:49:43 +0800 Subject: [PATCH 304/431] Improve spec test execution by adding retry logic for transient errors (#4393) --- .github/workflows/compilation_on_sgx.yml | 44 ++++++++++-------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index e6cc291081..3033c270e3 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -288,30 +288,24 @@ jobs: sudo swapon /swapfile sudo swapon --show - - name: run spec tests - run: | - set +e - source /opt/intel/sgxsdk/environment - attempts=0 - max_attempts=3 - - while [ $attempts -lt $max_attempts ]; do + - name: run spec tests with retry + id: run_spec_tests + uses: nick-fields/retry@v3 + with: + command: | + cd ./tests/wamr-test-suites + source /opt/intel/sgxsdk/environment ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} - exitcode="$?" + max_attempts: 3 + retry_on: error + shell: bash + timeout_minutes: 10 - 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 + - name: print test results + run: | + echo "Test results:" + echo "${{ steps.run_spec_tests.outputs.stdout }}" + echo "${{ steps.run_spec_tests.outputs.stderr }}" + echo "Exit code: ${{ steps.run_spec_tests.outputs.exit_code }}" + echo "Exit error: ${{ steps.run_spec_tests.outputs.exit_error }}" + shell: bash From f449b79a311c3cabdc4c925afa2d0a9f52ceab04 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 20 Jun 2025 16:50:29 +0900 Subject: [PATCH 305/431] wasi_nn_openvino.c: implement multiple models per instance (#4380) tested with two models: ``` --load-graph=id=graph1,file=public/license-plate-recognition-barrier-0007/FP32/license-plate-recognition-barrier-0007.xml,file=public/license-plate-recognition-barrier-0007/FP32/license-plate-recognition-barrier-0007.bin \ --load-graph=id=graph2,file=classify/model.xml,file=classify/model.bin \ --init-execution-context=id=exec1,graph-id=graph1 \ --init-execution-context=id=exec2,graph-id=graph2 \ --set-input=context-id=exec1,dim=1,dim=24,dim=94,dim=3,file=out.bin \ --set-input=context-id=exec2,file=classify/banana-3x224x224-bgr.bin,dim=1,dim=3,dim=224,dim=224 \ --compute=context-id=exec1 \ --compute=context-id=exec2 \ --get-output=context-id=exec1,file=exec1-result.bin \ --get-output=context-id=exec2,file=exec2-result.bin ``` a detailed HOWTO: https://github.com/bytecodealliance/wasm-micro-runtime/pull/4380#issuecomment-2986882718 --- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 177 +++++++++++++----- 1 file changed, 133 insertions(+), 44 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 1cd1625d64..3c3b0ae6c2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -26,15 +26,25 @@ * from 4. to 6. is the Inference Loop */ +/* these limits are arbitrary. */ +#define MAX_GRAPHS 4 +#define MAX_EXECUTION_CONTEXTS 4 + typedef struct { ov_core_t *core; /* keep input model files */ - void *weight_data; - ov_tensor_t *weights_tensor; - ov_model_t *model; - ov_compiled_model_t *compiled_model; - ov_infer_request_t *infer_request; - ov_tensor_t *input_tensor; + struct OpenVINOGraph { + void *weight_data; + ov_tensor_t *weights_tensor; + ov_model_t *model; + ov_compiled_model_t *compiled_model; + } graphs[MAX_GRAPHS]; + struct OpenVINOExecutionContext { + struct OpenVINOGraph *graph; + ov_infer_request_t *infer_request; + } execution_contexts[MAX_EXECUTION_CONTEXTS]; + unsigned int n_graphs; + unsigned int n_execution_contexts; } OpenVINOContext; /* @@ -179,6 +189,29 @@ wasi_nn_tensor_type_to_openvino_element_type(tensor_type wasi_nn_type) return UNDEFINED; } +static void +free_graph(struct OpenVINOGraph *graph) +{ + if (graph->weight_data) + os_free(graph->weight_data); + + if (graph->weights_tensor) + ov_tensor_free(graph->weights_tensor); + + if (graph->model) + ov_model_free(graph->model); + + if (graph->compiled_model) + ov_compiled_model_free(graph->compiled_model); +} + +static void +free_execution_context(struct OpenVINOExecutionContext *c) +{ + if (c->infer_request) + ov_infer_request_free(c->infer_request); +} + static wasi_nn_error uint32_array_to_int64_array(uint32_t array_size, uint32_t *src, int64_t **dst) { @@ -198,6 +231,8 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding, execution_target target, graph *g) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOGraph *graph; + unsigned int graph_idx; wasi_nn_error ret = unsupported_operation; if (encoding != openvino) { @@ -223,33 +258,47 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding, graph_builder xml = builder->buf[0]; graph_builder weight = builder->buf[1]; + graph_idx = ov_ctx->n_graphs; + if (graph_idx >= MAX_GRAPHS) { + return runtime_error; + } + graph = &ov_ctx->graphs[graph_idx]; + memset(graph, 0, sizeof(*graph)); + /* transfer weight to an ov tensor */ { - ov_ctx->weight_data = os_malloc(weight.size); - if (!ov_ctx->weight_data) + graph->weight_data = os_malloc(weight.size); + if (!graph->weight_data) goto fail; - memcpy(ov_ctx->weight_data, weight.buf, weight.size); + memcpy(graph->weight_data, weight.buf, weight.size); ov_element_type_e type = U8; int64_t dims[1] = { weight.size }; ov_shape_t shape = { 1, dims }; CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(type, shape, - ov_ctx->weight_data, - &ov_ctx->weights_tensor), + graph->weight_data, + &graph->weights_tensor), ret); } /* load model from buffer */ CHECK_OV_STATUS(ov_core_read_model_from_memory_buffer( ov_ctx->core, (char *)xml.buf, xml.size, - ov_ctx->weights_tensor, &ov_ctx->model), + graph->weights_tensor, &graph->model), ret); #ifndef NDEBUG print_model_input_output_info(ov_ctx->model); #endif - ret = success; + CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, graph->model, "CPU", 0, + &graph->compiled_model), + ret); + + *g = graph_idx; + ov_ctx->n_graphs++; + return success; fail: + free_graph(graph); return ret; } @@ -257,20 +306,62 @@ __attribute__((visibility("default"))) wasi_nn_error load_by_name(void *ctx, const char *filename, uint32_t filename_len, graph *g) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOGraph *graph; + unsigned int graph_idx; wasi_nn_error ret = unsupported_operation; + graph_idx = ov_ctx->n_graphs; + if (graph_idx >= MAX_GRAPHS) { + return runtime_error; + } + graph = &ov_ctx->graphs[graph_idx]; + + memset(graph, 0, sizeof(*graph)); CHECK_OV_STATUS( - ov_core_read_model(ov_ctx->core, filename, NULL, &ov_ctx->model), ret); + ov_core_read_model(ov_ctx->core, filename, NULL, &graph->model), ret); - ret = success; + CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, graph->model, "CPU", 0, + &graph->compiled_model), + ret); + + *g = graph_idx; + ov_ctx->n_graphs++; + return success; fail: + free_graph(graph); return ret; } __attribute__((visibility("default"))) wasi_nn_error init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx) { + OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOGraph *graph; + struct OpenVINOExecutionContext *exec; + unsigned int exec_idx; + wasi_nn_error ret; + + if (g >= ov_ctx->n_graphs) + return runtime_error; + graph = &ov_ctx->graphs[g]; + + exec_idx = ov_ctx->n_execution_contexts; + if (exec_idx >= MAX_EXECUTION_CONTEXTS) + return runtime_error; + exec = &ov_ctx->execution_contexts[exec_idx]; + + memset(exec, 0, sizeof(*exec)); + exec->graph = graph; + + CHECK_OV_STATUS(ov_compiled_model_create_infer_request( + graph->compiled_model, &exec->infer_request), + ret); + + *exec_ctx = exec_idx; + ov_ctx->n_execution_contexts++; return success; +fail: + return ret; } __attribute__((visibility("default"))) wasi_nn_error @@ -278,10 +369,16 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, tensor *wasi_nn_tensor) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOExecutionContext *exec; wasi_nn_error ret = unsupported_operation; ov_shape_t input_shape = { 0 }; + ov_tensor_t *input_tensor = NULL; int64_t *ov_dims = NULL; + if (exec_ctx >= ov_ctx->n_execution_contexts) + return runtime_error; + exec = &ov_ctx->execution_contexts[exec_ctx]; + /* wasi_nn_tensor -> ov_tensor */ { ret = uint32_array_to_int64_array(wasi_nn_tensor->dimensions->size, @@ -306,27 +403,20 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(input_type, input_shape, wasi_nn_tensor->data, - &ov_ctx->input_tensor), + &input_tensor), ret); } - CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, ov_ctx->model, "CPU", 0, - &ov_ctx->compiled_model), - ret); - - CHECK_OV_STATUS(ov_compiled_model_create_infer_request( - ov_ctx->compiled_model, &ov_ctx->infer_request), - ret); - /* install ov_tensor -> infer_request */ CHECK_OV_STATUS(ov_infer_request_set_input_tensor_by_index( - ov_ctx->infer_request, index, ov_ctx->input_tensor), + exec->infer_request, index, input_tensor), ret); ret = success; - fail: if (ov_dims) os_free(ov_dims); + if (input_tensor) + ov_tensor_free(input_tensor); ov_shape_free(&input_shape); return ret; @@ -336,9 +426,14 @@ __attribute__((visibility("default"))) wasi_nn_error compute(void *ctx, graph_execution_context exec_ctx) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOExecutionContext *exec; wasi_nn_error ret = unsupported_operation; - CHECK_OV_STATUS(ov_infer_request_infer(ov_ctx->infer_request), ret); + if (exec_ctx >= ov_ctx->n_execution_contexts) + return runtime_error; + exec = &ov_ctx->execution_contexts[exec_ctx]; + + CHECK_OV_STATUS(ov_infer_request_infer(exec->infer_request), ret); ret = success; fail: return ret; @@ -349,13 +444,18 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, tensor_data output_tensor, uint32_t *output_tensor_size) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + struct OpenVINOExecutionContext *exec; wasi_nn_error ret = unsupported_operation; ov_tensor_t *ov_tensor = NULL; void *data = NULL; size_t byte_size = 0; + if (exec_ctx >= ov_ctx->n_execution_contexts) + return runtime_error; + exec = &ov_ctx->execution_contexts[exec_ctx]; + CHECK_OV_STATUS(ov_infer_request_get_output_tensor_by_index( - ov_ctx->infer_request, index, &ov_tensor), + exec->infer_request, index, &ov_tensor), ret); CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret); @@ -421,27 +521,16 @@ __attribute__((visibility("default"))) wasi_nn_error deinit_backend(void *ctx) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; + unsigned int i; if (!ov_ctx) return invalid_argument; - if (ov_ctx->weight_data) - os_free(ov_ctx->weight_data); - - if (ov_ctx->weights_tensor) - ov_tensor_free(ov_ctx->weights_tensor); - - if (ov_ctx->input_tensor) - ov_tensor_free(ov_ctx->input_tensor); - - if (ov_ctx->infer_request) - ov_infer_request_free(ov_ctx->infer_request); - - if (ov_ctx->compiled_model) - ov_compiled_model_free(ov_ctx->compiled_model); + for (i = 0; i < ov_ctx->n_execution_contexts; i++) + free_execution_context(&ov_ctx->execution_contexts[i]); - if (ov_ctx->model) - ov_model_free(ov_ctx->model); + for (i = 0; i < ov_ctx->n_graphs; i++) + free_graph(&ov_ctx->graphs[i]); if (ov_ctx->core) ov_core_free(ov_ctx->core); From 7471d5a5d005c08334fa7a87360267dba38569f4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 20 Jun 2025 16:50:48 +0900 Subject: [PATCH 306/431] wamr-wasi-extensions/socket: disable reference-types (#4392) and add a comment to explain why. --- wamr-wasi-extensions/socket/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wamr-wasi-extensions/socket/CMakeLists.txt b/wamr-wasi-extensions/socket/CMakeLists.txt index 0ffdd453b5..74bbf31c4d 100644 --- a/wamr-wasi-extensions/socket/CMakeLists.txt +++ b/wamr-wasi-extensions/socket/CMakeLists.txt @@ -13,6 +13,12 @@ target_include_directories(wamr-wasi-socket $ $) +# as this is a library, be extra conservative about wasm features +# to improve compatibilities. as this particular library is just a +# simple static stub, extra wasm features won't benefit us much anyway. +# note that LLVM-19 enables reference-types by default. +target_compile_options(wamr-wasi-socket PRIVATE -mno-reference-types) + install(TARGETS wamr-wasi-socket EXPORT wamr-wasi-socket-config PUBLIC_HEADER DESTINATION include) From 92e5f5f123b54ce1ef5b5645da96f70fff61a93a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 24 Jun 2025 21:35:19 +0900 Subject: [PATCH 307/431] CI: fix the description of upload_url (#4407) --- .github/workflows/build_iwasm_release.yml | 2 +- .github/workflows/build_wamrc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_iwasm_release.yml b/.github/workflows/build_iwasm_release.yml index a975d58073..6acd90fa64 100644 --- a/.github/workflows/build_iwasm_release.yml +++ b/.github/workflows/build_iwasm_release.yml @@ -23,7 +23,7 @@ on: type: string required: true upload_url: - description: a semantic version number. it is required when `release` is true. + description: upload binary assets to the URL of release type: string required: false ver_num: diff --git a/.github/workflows/build_wamrc.yml b/.github/workflows/build_wamrc.yml index 55d63f13ba..07e3c7cdb0 100644 --- a/.github/workflows/build_wamrc.yml +++ b/.github/workflows/build_wamrc.yml @@ -23,7 +23,7 @@ on: type: string required: true upload_url: - description: a semantic version number. it is required when `release` is true. + description: upload binary assets to the URL of release type: string required: false ver_num: From 70c39bae77d011dbd4883fe6d2999a4deb089602 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 24 Jun 2025 21:37:56 +0900 Subject: [PATCH 308/431] wasi-nn: fix context lifetime issues (#4396) * wasi-nn: fix context lifetime issues use the module instance context api instead of trying to roll our own with a hashmap. this fixes context lifetime problems mentioned in https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313. namely, * wasi-nn resources will be freed earlier now. before this change, they used to be kept until the runtime shutdown. (wasm_runtime_destroy) after this change, they will be freed together with the associated instances. * wasm_module_inst_t pointer uniqueness assumption (which is wrong after wasm_runtime_deinstantiate) was lifted. as a side effect, this change also makes a context shared among threads within a cluster. note that this is a user-visible api/abi breaking change. before this change, wasi-nn "handles" like wasi_ephemeral_nn_graph were thread-local. after this change, they are shared among threads within a cluster, similarly to wasi file descriptors. spec-wise, either behavior should be ok simply because wasi officially doesn't have threads yet. althogh i feel the latter semantics is more intuitive, if your application depends on the thread-local behavior, this change breaks your application. tested with wamr-wasi-extensions/samples/nn-cli, modified to call each wasi-nn operations on different threads. (if you are interested, you can find the modification at https://github.com/yamt/wasm-micro-runtime/tree/yamt-nn-wip-20250619.) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313 https://github.com/bytecodealliance/wasm-micro-runtime/issues/2430 * runtime_lib.cmake: enable WAMR_BUILD_MODULE_INST_CONTEXT for wasi-nn as we do for wasi (WAMR_BUILD_LIBC_WASI) --- build-scripts/runtime_lib.cmake | 1 + core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 78 ++++++---------------- 2 files changed, 22 insertions(+), 57 deletions(-) diff --git a/build-scripts/runtime_lib.cmake b/build-scripts/runtime_lib.cmake index e538b5d914..f7639f6a61 100644 --- a/build-scripts/runtime_lib.cmake +++ b/build-scripts/runtime_lib.cmake @@ -106,6 +106,7 @@ endif () if (WAMR_BUILD_WASI_NN EQUAL 1) include (${IWASM_DIR}/libraries/wasi-nn/cmake/wasi_nn.cmake) + set (WAMR_BUILD_MODULE_INST_CONTEXT 1) endif () if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 5c916aa4a1..25d70e6a94 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -55,49 +55,15 @@ struct backends_api_functions { NN_ERR_PRINTF("Error %s() -> %d", #func, wasi_error); \ } while (0) -/* HashMap utils */ -static HashMap *hashmap; - -static uint32 -hash_func(const void *key) -{ - // fnv1a_hash - const uint32 FNV_PRIME = 16777619; - const uint32 FNV_OFFSET_BASIS = 2166136261U; - - uint32 hash = FNV_OFFSET_BASIS; - const unsigned char *bytes = (const unsigned char *)key; - - for (size_t i = 0; i < sizeof(uintptr_t); ++i) { - hash ^= bytes[i]; - hash *= FNV_PRIME; - } - - return hash; -} - -static bool -key_equal_func(void *key1, void *key2) -{ - return key1 == key2; -} - -static void -key_destroy_func(void *key1) -{ - /* key type is wasm_module_inst_t*. do nothing */ -} +static void *wasi_nn_key; static void wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) { - NN_DBG_PRINTF("[WASI NN] DEINIT..."); - if (wasi_nn_ctx == NULL) { - NN_ERR_PRINTF( - "Error when deallocating memory. WASI-NN context is NULL"); return; } + NN_DBG_PRINTF("[WASI NN] DEINIT..."); NN_DBG_PRINTF("Freeing wasi-nn"); NN_DBG_PRINTF("-> is_model_loaded: %d", wasi_nn_ctx->is_model_loaded); NN_DBG_PRINTF("-> current_encoding: %d", wasi_nn_ctx->backend); @@ -116,9 +82,9 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) } static void -value_destroy_func(void *value) +dtor(wasm_module_inst_t inst, void *ctx) { - wasi_nn_ctx_destroy((WASINNContext *)value); + wasi_nn_ctx_destroy(ctx); } bool @@ -131,12 +97,9 @@ wasi_nn_initialize() 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"); + wasi_nn_key = wasm_runtime_create_context_key(dtor); + if (wasi_nn_key == NULL) { + NN_ERR_PRINTF("Failed to create context key"); os_mutex_destroy(&wasi_nn_lock); return false; } @@ -170,21 +133,23 @@ static WASINNContext * wasm_runtime_get_wasi_nn_ctx(wasm_module_inst_t instance) { WASINNContext *wasi_nn_ctx = - (WASINNContext *)bh_hash_map_find(hashmap, (void *)instance); + wasm_runtime_get_context(instance, wasi_nn_key); if (wasi_nn_ctx == NULL) { - wasi_nn_ctx = wasi_nn_initialize_context(); - if (wasi_nn_ctx == NULL) - return NULL; - - bool ok = - bh_hash_map_insert(hashmap, (void *)instance, (void *)wasi_nn_ctx); - if (!ok) { - NN_ERR_PRINTF("Error while storing context"); - wasi_nn_ctx_destroy(wasi_nn_ctx); + WASINNContext *newctx = wasi_nn_initialize_context(); + if (newctx == NULL) return NULL; + os_mutex_lock(&wasi_nn_lock); + wasi_nn_ctx = wasm_runtime_get_context(instance, wasi_nn_key); + if (wasi_nn_ctx == NULL) { + wasm_runtime_set_context_spread(instance, wasi_nn_key, newctx); + wasi_nn_ctx = newctx; + newctx = NULL; + } + os_mutex_unlock(&wasi_nn_lock); + if (newctx != NULL) { + wasi_nn_ctx_destroy(newctx); } } - return wasi_nn_ctx; } @@ -220,8 +185,7 @@ unlock_ctx(WASINNContext *wasi_nn_ctx) void wasi_nn_destroy() { - // destroy hashmap will destroy keys and values - bh_hash_map_destroy(hashmap); + wasm_runtime_destroy_context_key(wasi_nn_key); // close backends' libraries and registered functions for (unsigned i = 0; i < sizeof(lookup) / sizeof(lookup[0]); i++) { From 8289452abbf22b136513da1f685a657ccb05c8a4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 24 Jun 2025 21:38:19 +0900 Subject: [PATCH 309/431] wasi_nn_tensorflowlite.cpp: fix get_output return size (#4390) it should be byte size, not the number of (fp32) values. i'm ambivalent about how to deal with the compatibility for the legacy wamr-specific "wasi_nn". for now, i avoided changing it. (so that existing tests using the legacy abi, namely test_tensorflow.c and test_tensorflow_quantized.c, passes as they are.) if we have any users who still want to use the legacy abi, i suppose they consider the compatibility is more important than the consistency with other backends. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4376 --- .../wasi-nn/src/wasi_nn_tensorflowlite.cpp | 73 +++++++++++++++---- 1 file changed, 57 insertions(+), 16 deletions(-) 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 9c458179ab..c9064a5ec3 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -389,23 +389,34 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, return too_large; } - uint32_t model_tensor_size = 1; - for (int i = 0; i < (int)tensor->dims->size; ++i) - model_tensor_size *= (uint32_t)tensor->dims->data[i]; - - if (*output_tensor_size < model_tensor_size) { - NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); - return too_large; - } - if (tensor->quantization.type == kTfLiteNoQuantization) { NN_DBG_PRINTF("No quantization information"); - float *ot = - tfl_ctx->interpreters[ctx].interpreter->typed_output_tensor( - index); - - int size = model_tensor_size * sizeof(float); - bh_memcpy_s(output_tensor, size, ot, size); +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 + if (*output_tensor_size < tensor->bytes) { + NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); + return too_large; + } +#else + /* + * for now, maintain the bug-to-bug compatibility with the old abi, + * where the size here is the number of fp32, not bytes. + */ + if (*output_tensor_size < tensor->bytes / sizeof(float)) { + NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); + return too_large; + } +#endif + bh_memcpy_s(output_tensor, *output_tensor_size, tensor->data.data, + tensor->bytes); +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 + *output_tensor_size = tensor->bytes; +#else + /* + * for now, maintain the bug-to-bug compatibility with the old abi, + * where the size here is the number of fp32, not bytes. + */ + *output_tensor_size = tensor->bytes / sizeof(float); +#endif } else { // TODO: Assuming uint8 quantized networks. TfLiteAffineQuantization *quant_info = @@ -414,6 +425,27 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, NN_ERR_PRINTF("Quantization per channel is not supported"); return runtime_error; } + + uint32_t model_tensor_size = 1; + for (int i = 0; i < (int)tensor->dims->size; ++i) + model_tensor_size *= (uint32_t)tensor->dims->data[i]; + +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 + if (*output_tensor_size / sizeof(float) < model_tensor_size) { + NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); + return too_large; + } +#else + /* + * for now, maintain the bug-to-bug compatibility with the old abi, + * where the size here is the number of fp32, not bytes. + */ + if (*output_tensor_size < model_tensor_size) { + NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); + return too_large; + } +#endif + uint8_t *ot = tfl_ctx->interpreters[ctx] .interpreter->typed_output_tensor(index); @@ -426,9 +458,18 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, for (uint32_t i = 0; i < model_tensor_size; ++i) { output_tensor_f[i] = (ot[i] - zero_point) * scale; } + +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 + *output_tensor_size = model_tensor_size * sizeof(float); +#else + /* + * for now, maintain the bug-to-bug compatibility with the old abi, + * where the size here is the number of fp32, not bytes. + */ + *output_tensor_size = model_tensor_size; +#endif } - *output_tensor_size = model_tensor_size; return success; } From e414a327a0d0afaaf13ec4036f2b4f05c8a81c64 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 24 Jun 2025 20:38:30 +0800 Subject: [PATCH 310/431] Refactor copy callstack feature (#4401) - Change `WAMR_ENABLE_COPY_CALLSTACK` to `WAMR_BUILD_COPY_CALL_STACK`, as `WAMR_BUILD` is the prefix for a command line option. - Change `WAMR_ENABLE_COPY_CALLSTACK` to `WASM_ENABLE_COPY_CALL_STACK`, as `WASM_ENABLE` is the prefix for a macro in the source code. - Change `CALLSTACK` to `CALL_STACK` to align with the existing `DUMP_CALL_STACK` feature. - Continue using `WASMCApiFrame` instead of `wasm_frame_t` outside of *wasm_c_api.xxx* to avoid a typedef redefinition warning, which is identified by Clang. --- CMakeLists.txt | 4 ++-- build-scripts/config_common.cmake | 9 ++------- core/config.h | 4 ++-- core/iwasm/aot/aot_runtime.c | 10 +++++----- core/iwasm/aot/aot_runtime.h | 6 +++--- core/iwasm/common/wasm_runtime_common.c | 6 +++--- core/iwasm/common/wasm_runtime_common.h | 6 +++--- core/iwasm/include/wasm_export.h | 4 +--- core/iwasm/interpreter/wasm_runtime.c | 6 +++--- core/iwasm/interpreter/wasm_runtime.h | 6 +++--- 10 files changed, 27 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a1642b8e..4b28fa89c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,9 +99,9 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS) set (WAMR_BUILD_LIB_WASI_THREADS 0) endif () -if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK) +if (NOT DEFINED WAMR_BUILD_COPY_CALL_STACK) # Disable copy callstack by default - set (WAMR_ENABLE_COPY_CALLSTACK 0) + set (WAMR_BUILD_COPY_CALL_STACK 0) endif() if (NOT DEFINED WAMR_BUILD_MINI_LOADER) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index b4013210ab..ca9360a633 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -334,15 +334,10 @@ if (WAMR_BUILD_SHARED_HEAP EQUAL 1) add_definitions (-DWASM_ENABLE_SHARED_HEAP=1) message (" Shared heap enabled") endif() - -if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1) - add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1) +if (WAMR_BUILD_COPY_CALL_STACK EQUAL 1) + add_definitions (-DWASM_ENABLE_COPY_CALL_STACK=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/config.h b/core/config.h index a4e1499e35..c43a1bfe44 100644 --- a/core/config.h +++ b/core/config.h @@ -193,8 +193,8 @@ #error "Heap aux stack allocation must be enabled for WASI threads" #endif -#ifndef WAMR_ENABLE_COPY_CALLSTACK -#define WAMR_ENABLE_COPY_CALLSTACK 0 +#ifndef WASM_ENABLE_COPY_CALL_STACK +#define WASM_ENABLE_COPY_CALL_STACK 0 #endif #ifndef WASM_ENABLE_BASE_LIB diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index c5e1431897..f93e03dac7 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4137,9 +4137,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) } #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */ -#if WAMR_ENABLE_COPY_CALLSTACK != 0 +#if WASM_ENABLE_COPY_CALL_STACK != 0 uint32 -aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, +aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32 error_buf_size) { @@ -4193,7 +4193,7 @@ 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, +aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size) { @@ -4243,7 +4243,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, } uint32 -aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, +aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size) { @@ -4265,7 +4265,7 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, error_buf, error_buf_size); } } -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK #if WASM_ENABLE_DUMP_CALL_STACK != 0 bool diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index e5678a8d61..e957f3959f 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -787,12 +787,12 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame); bool aot_create_call_stack(struct WASMExecEnv *exec_env); -#if WAMR_ENABLE_COPY_CALLSTACK != 0 +#if WASM_ENABLE_COPY_CALL_STACK != 0 uint32 -aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, +aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size); -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK /** * @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 dcee0aeafc..e1d3542b96 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1743,9 +1743,9 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) wasm_exec_env_destroy(exec_env); } -#if WAMR_ENABLE_COPY_CALLSTACK != 0 +#if WASM_ENABLE_COPY_CALL_STACK != 0 uint32 -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, +wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size) { @@ -1780,7 +1780,7 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, strncpy(error_buf, err_msg, error_buf_size); return 0; } -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK 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 64a6cd7936..ad22ea10ba 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -758,12 +758,12 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); -#if WAMR_ENABLE_COPY_CALLSTACK != 0 +#if WASM_ENABLE_COPY_CALL_STACK != 0 WASM_RUNTIME_API_EXTERN uint32_t -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, +wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer, const uint32 length, const uint32 skip_n, char *error_buf, uint32 error_buf_size); -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK /* 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 b4ab34bea7..ca96f5824d 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -139,8 +139,6 @@ typedef struct wasm_frame_t { uint32_t *lp; } WASMCApiFrame; -typedef WASMCApiFrame wasm_frame_t; - /* WASM section */ typedef struct wasm_section_t { struct wasm_section_t *next; @@ -904,7 +902,7 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); * @return number of copied frames */ WASM_RUNTIME_API_EXTERN uint32_t -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, +wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer, const uint32_t length, const uint32_t skip_n, char *error_buf, uint32_t error_buf_size); diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 3cc2afe04d..15d07ae982 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4195,9 +4195,9 @@ 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 +#if WASM_ENABLE_COPY_CALL_STACK != 0 uint32 -wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, +wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer, uint32 length, uint32 skip_n, char *error_buf, uint32_t error_buf_size) { @@ -4242,7 +4242,7 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, } return count >= skip_n ? count - skip_n : 0; } -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK #if WASM_ENABLE_DUMP_CALL_STACK != 0 bool diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 8d38c8831c..3d91d8b601 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -731,12 +731,12 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WASM_ENABLE_DUMP_CALL_STACK != 0 -#if WAMR_ENABLE_COPY_CALLSTACK != 0 +#if WASM_ENABLE_COPY_CALL_STACK != 0 uint32 -wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, +wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer, uint32 length, uint32 skip_n, char *error_buf, uint32_t error_buf_size); -#endif // WAMR_ENABLE_COPY_CALLSTACK +#endif // WASM_ENABLE_COPY_CALL_STACK bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env); From 1e41519977142a003db6650f3054ad3e121dac65 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:38:39 +0800 Subject: [PATCH 311/431] loader: add type index checking (#4402) --- core/iwasm/aot/aot_loader.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index f274471f35..9d1129b8d6 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1730,6 +1730,12 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, (void)u8; read_uint32(buf, buf_end, j); +#if WASM_ENABLE_AOT_VALIDATOR != 0 + if (j >= module->type_count) { + set_error_buf(error_buf, error_buf_size, "invalid type index"); + goto fail; + } +#endif if (module->types[j]->ref_count == UINT16_MAX) { set_error_buf(error_buf, error_buf_size, "wasm type's ref count too large"); @@ -1993,6 +1999,13 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, AOTType *cur_type = module->types[j]; parent_type_idx = cur_type->parent_type_idx; if (parent_type_idx != (uint32)-1) { /* has parent */ +#if WASM_ENABLE_AOT_VALIDATOR != 0 + if (parent_type_idx >= module->type_count) { + set_error_buf(error_buf, error_buf_size, + "invalid parent type index"); + goto fail; + } +#endif AOTType *parent_type = module->types[parent_type_idx]; module->types[j]->parent_type = parent_type; @@ -2016,6 +2029,13 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, AOTType *cur_type = module->types[j]; parent_type_idx = cur_type->parent_type_idx; if (parent_type_idx != (uint32)-1) { /* has parent */ +#if WASM_ENABLE_AOT_VALIDATOR != 0 + if (parent_type_idx >= module->type_count) { + set_error_buf(error_buf, error_buf_size, + "invalid parent type index"); + goto fail; + } +#endif AOTType *parent_type = module->types[parent_type_idx]; /* subtyping has been checked during compilation */ bh_assert(wasm_type_is_subtype_of( From 535004dedcfada72df40d06a3c45d9d6f9e2d55f Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Thu, 26 Jun 2025 06:59:57 +0800 Subject: [PATCH 312/431] Fix handling of non-nullable global_type during global import (#4408) --- 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 c8b4e6b7d9..907db9226f 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3351,7 +3351,8 @@ 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_reftype_htref_nullable(global_type)) { + if (wasm_is_reftype_htref_nullable(global_type) + || wasm_is_reftype_htref_non_nullable(global_type)) { int32 heap_type; read_leb_int32(p, p_end, heap_type); (void)heap_type; From a7aae9d2cc03ac806ad574f60673ae81b705184f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 26 Jun 2025 08:05:45 +0900 Subject: [PATCH 313/431] wasi_nn_llamacpp.c: make this compilable (#4403) --- core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 23c867b0ab..ff31e3adb2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -2,6 +2,9 @@ * Copyright (C) 2019 Intel Corporation. All rights reserved. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ + +#include + #include "wasi_nn_types.h" #include "utils/logger.h" #include "llama.h" @@ -286,7 +289,7 @@ deinit_backend(void *ctx) llama_backend_free(); - os_free(backend_ctx); + free(backend_ctx); return success; } From 5b3213095518fae7c1565a9ca045ad0a43ec16f4 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:18:24 +0800 Subject: [PATCH 314/431] fix bug in bh_vector when extending (#4414) --- core/shared/utils/bh_vector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/shared/utils/bh_vector.c b/core/shared/utils/bh_vector.c index 352ce71923..40dc2772d9 100644 --- a/core/shared/utils/bh_vector.c +++ b/core/shared/utils/bh_vector.c @@ -35,8 +35,8 @@ extend_vector(Vector *vector, size_t length) if (length <= vector->max_elems) return true; - if (length < vector->size_elem * 3 / 2) - length = vector->size_elem * 3 / 2; + if (length < vector->max_elems * 3 / 2) + length = vector->max_elems * 3 / 2; if (!(data = alloc_vector_data(length, vector->size_elem))) { return false; From 23799a2cb6778896e5e7797d17bc826e1afdbf6e Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:20:40 +0800 Subject: [PATCH 315/431] Collective fix (#4413) * Fix vector growth check and typos in core (#9) * Fix resource cleanup in memory and running modes tests (#10) * Add end of file empty line in wasm_running_modes_test.cc --- ci/coding_guidelines_check.py | 3 +-- core/iwasm/compilation/aot_llvm.c | 4 +-- core/iwasm/interpreter/wasm_runtime.c | 2 +- core/shared/utils/bh_vector.c | 4 +-- .../fuzz/wasm-mutator-fuzz/server/app/main.py | 26 +++++++++---------- .../gc-aot/build_spec_interpreter.sh | 4 +-- .../test_c_embed_api_thoroughly.py | 14 +++++----- .../test_iwasm_thoroughly.py | 2 +- tests/unit/memory64/memory64_atomic_test.cc | 4 ++- tests/unit/memory64/memory64_test.cc | 10 ++++--- .../running-modes/wasm_running_modes_test.cc | 24 +++++++++-------- tests/wamr-test-suites/test_wamr.sh | 2 +- 12 files changed, 52 insertions(+), 47 deletions(-) diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index 43c3662590..131bca5b61 100644 --- a/ci/coding_guidelines_check.py +++ b/ci/coding_guidelines_check.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # import argparse -import re from pathlib import Path import re import shlex @@ -39,7 +38,7 @@ def locate_command(command: str) -> bool: if not shutil.which(command): - print(f"Command '{command}'' not found") + print(f"Command '{command}' not found") return False return True diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 7cbb4a57e3..28b0da0a6c 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -3999,7 +3999,7 @@ aot_get_func_from_table(const AOTCompContext *comp_ctx, LLVMValueRef base, if (!(func = LLVMBuildBitCast(comp_ctx->builder, func, func_type, "func"))) { - aot_set_last_error("cast function fialed."); + aot_set_last_error("cast function failed."); goto fail; } @@ -4068,7 +4068,7 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base, if (!(const_addr = LLVMBuildBitCast(comp_ctx->builder, const_addr, const_ptr_type, "const_addr"))) { - aot_set_last_error("cast const fialed."); + aot_set_last_error("cast const failed."); return NULL; } diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 15d07ae982..78af146abf 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -2668,7 +2668,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, } STORE_PTR((void **)global_data, func_obj); global_data += sizeof(void *); - /* Also update the inital_value since other globals may + /* Also update the initial_value since other globals may * refer to this */ global->initial_value.gc_obj = (wasm_obj_t)func_obj; break; diff --git a/core/shared/utils/bh_vector.c b/core/shared/utils/bh_vector.c index 40dc2772d9..7f0c74b9ba 100644 --- a/core/shared/utils/bh_vector.c +++ b/core/shared/utils/bh_vector.c @@ -194,12 +194,12 @@ bh_vector_append(Vector *vector, const void *elem_buf) goto just_return; } - /* make sure one more slot is used by the thread who allocas it */ + /* make sure one more slot is used by the thread who allocates it */ if (vector->lock) os_mutex_lock(vector->lock); if (!extend_vector(vector, vector->num_elems + 1)) { - LOG_ERROR("Append ector elem failed: extend vector failed.\n"); + LOG_ERROR("Append vector elem failed: extend vector failed.\n"); goto unlock_return; } diff --git a/tests/fuzz/wasm-mutator-fuzz/server/app/main.py b/tests/fuzz/wasm-mutator-fuzz/server/app/main.py index 620625dd33..c1ee3bfc4c 100644 --- a/tests/fuzz/wasm-mutator-fuzz/server/app/main.py +++ b/tests/fuzz/wasm-mutator-fuzz/server/app/main.py @@ -72,7 +72,7 @@ def to_json(inst, cls): class Fuzzing(db.Model): - __tablename__ = 'fazzing_task' + __tablename__ = 'fuzzing_task' id = db.Column(db.Integer, autoincrement=True, primary_key=True, nullable=False) repo = db.Column(db.String(200), nullable=False, default='') @@ -96,7 +96,7 @@ class TaskError(db.Model): __tablename__ = 'task_error' id = db.Column(db.Integer, autoincrement=True, primary_key=True, nullable=False) - fazzing_id = db.Column(db.Integer, db.ForeignKey("fazzing_task.id")) + fuzzing_id = db.Column(db.Integer, db.ForeignKey("fuzzing_task.id")) name = db.Column(db.String(200), nullable=False, default='') std_out = db.Column(db.Text, default='') data = db.Column(db.JSON) @@ -119,9 +119,9 @@ def to_data(data): def error_count(data): error = len(TaskError.query.filter( - TaskError.fazzing_id == data.get('id'), TaskError.status.in_([1, 2])).all()) + TaskError.fuzzing_id == data.get('id'), TaskError.status.in_([1, 2])).all()) end_error = len(TaskError.query.filter( - TaskError.fazzing_id == data.get('id'), TaskError.status == 0).all()) + TaskError.fuzzing_id == data.get('id'), TaskError.status == 0).all()) data['error'] = error data['end_error'] = end_error return data @@ -159,11 +159,11 @@ def show_fuzz_list(): id = data.get('id') if id: all_error = TaskError.query.filter( - TaskError.fazzing_id == id).with_entities(TaskError.id, TaskError.fazzing_id, + TaskError.fuzzing_id == id).with_entities(TaskError.id, TaskError.fuzzing_id, TaskError.create_time, TaskError.data, TaskError.name, TaskError.status, TaskError.update_time, TaskError.comment).order_by(TaskError.status.desc(), TaskError.update_time.desc(), TaskError.id.desc()).all() - data_message = [{'id': error['id'], "fuzzing_id": error['fazzing_id'], + data_message = [{'id': error['id'], "fuzzing_id": error['fuzzing_id'], "name": error['name'], "data": error['data'], 'create_time': error['create_time'].strftime('%Y-%m-%d %H:%M:%S'), 'update_time': error['update_time'].strftime('%Y-%m-%d %H:%M:%S'), @@ -204,7 +204,7 @@ def New_fuzzing(): # curd.set_error_status_to(list(map(lambda x: x.id, error_list)), db) # Fuzzing.query.filter_by(id=fuzz.id).delete() fuzz.data = {'error': "Clone repo Error"} - db.commit() + db.session.commit() return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"}) wamr_path_parent = fuzz_dir.parent.parent @@ -277,7 +277,7 @@ def scheduler_run_task(): for fuzz in fuzz_query: all_error = TaskError.query.filter( - TaskError.fazzing_id == fuzz.id).with_entities(TaskError.name).all() + TaskError.fuzzing_id == fuzz.id).with_entities(TaskError.name).all() fuzz_cmd = wasm_mutator_dir / \ 'workspace' / f'build_{fuzz.id}' dir_list = filter(lambda x: x.startswith( @@ -287,7 +287,7 @@ def scheduler_run_task(): for dir in dir_list: cmd = f'cd {fuzz_cmd} && ./wasm_mutator_fuzz {dir}' status, resp = getstatusoutput(cmd) - task_error = TaskError(name=dir, std_out=resp, fazzing_id=fuzz.id, + task_error = TaskError(name=dir, std_out=resp, fuzzing_id=fuzz.id, create_time=datetime.utcnow() + timedelta(hours=8)) db.session.add(task_error) db.session.commit() @@ -312,7 +312,7 @@ def get_error_txt(): return jsonify({"status": 0, "results": [], 'msg': "Error"}) error = TaskError.query.get(id) fuzz_cmd = wasm_mutator_dir / \ - 'workspace' / f'build_{error.fazzing_id}' + 'workspace' / f'build_{error.fuzzing_id}' file_cmd = fuzz_cmd / error.name response = send_file(file_cmd, as_attachment=True, @@ -351,7 +351,7 @@ def get_cases_zip(): with ZipFile(memory_file, "w", ZIP_DEFLATED) as zf: for task_error in task_query: fuzz_cmd = wasm_mutator_dir / \ - 'workspace' / f'build_{task_error.fazzing_id}' + 'workspace' / f'build_{task_error.fuzzing_id}' file_cmd = fuzz_cmd / task_error.name zf.write(str(file_cmd), arcname=task_error.name) memory_file.seek(0) @@ -399,7 +399,7 @@ def error_restart(): if run_status: return jsonify({"status": 0, "results": [], 'msg': "There are already tasks in progress"}) task_query = TaskError.query.filter(TaskError.id.in_(id_list)).all() - fuzzing_id = task_query[0].fazzing_id + fuzzing_id = task_query[0].fuzzing_id fuzz_cmd = wasm_mutator_dir / \ 'workspace' / f'build_{fuzzing_id}' restart_cmd = wasm_mutator_dir / \ @@ -412,7 +412,7 @@ def error_restart(): if not Path(restart_cmd / 'wamr').exists(): print('------ error: clone repo not folder exists ------') # fuzz.data = {'error': "Clone repo Error"} - db.commit() + db.session.commit() return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"}) wamr_path_parent = fuzz_dir.parent.parent wamr_path = wamr_path_parent / 'wamr' diff --git a/tests/requirement-engineering/gc-aot/build_spec_interpreter.sh b/tests/requirement-engineering/gc-aot/build_spec_interpreter.sh index 48d6343b18..0ecfe93f4a 100755 --- a/tests/requirement-engineering/gc-aot/build_spec_interpreter.sh +++ b/tests/requirement-engineering/gc-aot/build_spec_interpreter.sh @@ -17,7 +17,7 @@ git apply ../../../wamr-test-suites/spec-test-script/gc_ignore_cases.patch # Set OCaml compiler environment eval $(opam config env) -echo "compile the reference intepreter" +echo "compile the reference interpreter" pushd interpreter make -popd \ No newline at end of file +popd diff --git a/tests/standalone/test-running-modes/test_c_embed_api_thoroughly.py b/tests/standalone/test-running-modes/test_c_embed_api_thoroughly.py index 63e871e4a9..8dcde7e74b 100755 --- a/tests/standalone/test-running-modes/test_c_embed_api_thoroughly.py +++ b/tests/standalone/test-running-modes/test_c_embed_api_thoroughly.py @@ -9,7 +9,7 @@ from collections import OrderedDict -def CLI_ARGS_GENREATOR(running_modes_supported: list[str]) -> list[str]: +def CLI_ARGS_GENERATOR(running_modes_supported: list[str]) -> list[str]: res = [] list_2d = [["--default-running-mode={} --module-running-mode={}".format(i, j) for i in running_modes_supported] for j in running_modes_supported] @@ -35,16 +35,16 @@ def main(): ] # Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion. - # just to be safe, using orderreddict + # just to be safe, using OrderedDict # key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested} test_options = OrderedDict({ - "INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:1])}, - "FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:2])}, + "INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:1])}, + "FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:2])}, "LLVM_JIT": {"compile_flag": COMPILE_FLAGS[2], - "cli_args": CLI_ARGS_GENREATOR([RUNNING_MODES[0], RUNNING_MODES[2]])}, - "MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES)}, + "cli_args": CLI_ARGS_GENERATOR([RUNNING_MODES[0], RUNNING_MODES[2]])}, + "MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES)}, "EAGER_JIT_WITH_BOTH_JIT": {"compile_flag": COMPILE_FLAGS[4], - "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:3])} + "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:3])} }) build_cmd = "./build_c_embed.sh \"{build_flag}\"" diff --git a/tests/standalone/test-running-modes/test_iwasm_thoroughly.py b/tests/standalone/test-running-modes/test_iwasm_thoroughly.py index a5af29101c..3c631a6d53 100755 --- a/tests/standalone/test-running-modes/test_iwasm_thoroughly.py +++ b/tests/standalone/test-running-modes/test_iwasm_thoroughly.py @@ -29,7 +29,7 @@ def main(): ] # Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion. - # just to be safe, using orderreddict + # just to be safe, using OrderedDict # key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested} test_options = OrderedDict({ "INTERP": {"compile_flag": COMPILE_FLAGS[0], "iwasm_cli_args": IWASM_CLI_ARGS[:1]}, diff --git a/tests/unit/memory64/memory64_atomic_test.cc b/tests/unit/memory64/memory64_atomic_test.cc index 49295668d4..3b2f679b5c 100644 --- a/tests/unit/memory64/memory64_atomic_test.cc +++ b/tests/unit/memory64/memory64_atomic_test.cc @@ -31,7 +31,7 @@ class memory64_atomic_test_suite : public testing::TestWithParam return true; fail: - if (!module) + if (module) wasm_runtime_unload(module); return false; @@ -56,6 +56,8 @@ class memory64_atomic_test_suite : public testing::TestWithParam if (exec_env) wasm_runtime_destroy_exec_env(exec_env); if (module_inst) + wasm_runtime_deinstantiate(module_inst); + if (module) wasm_runtime_unload(module); return false; } diff --git a/tests/unit/memory64/memory64_test.cc b/tests/unit/memory64/memory64_test.cc index af36f308ca..2418d70ad1 100644 --- a/tests/unit/memory64/memory64_test.cc +++ b/tests/unit/memory64/memory64_test.cc @@ -31,7 +31,7 @@ class memory64_test_suite : public testing::TestWithParam return true; fail: - if (!module) + if (module) wasm_runtime_unload(module); return false; @@ -56,11 +56,13 @@ class memory64_test_suite : public testing::TestWithParam if (exec_env) wasm_runtime_destroy_exec_env(exec_env); if (module_inst) + wasm_runtime_deinstantiate(module_inst); + if (module) wasm_runtime_unload(module); return false; } - void destory_exec_env() + void destroy_exec_env() { wasm_runtime_destroy_exec_env(exec_env); wasm_runtime_deinstantiate(module_inst); @@ -201,7 +203,7 @@ TEST_P(memory64_test_suite, memory_8GB) i64 = 0xbeefdead; ASSERT_EQ(i64, GET_U64_FROM_ADDR(wasm_argv)); - destory_exec_env(); + destroy_exec_env(); } TEST_P(memory64_test_suite, mem64_from_clang) @@ -228,7 +230,7 @@ TEST_P(memory64_test_suite, mem64_from_clang) i32 = 0x109; ASSERT_EQ(i32, wasm_argv[0]); - destory_exec_env(); + destroy_exec_env(); } INSTANTIATE_TEST_CASE_P(RunningMode, memory64_test_suite, diff --git a/tests/unit/running-modes/wasm_running_modes_test.cc b/tests/unit/running-modes/wasm_running_modes_test.cc index e18e64fb1f..5f370dd649 100644 --- a/tests/unit/running-modes/wasm_running_modes_test.cc +++ b/tests/unit/running-modes/wasm_running_modes_test.cc @@ -21,7 +21,7 @@ std::string TEST_WASM1 = "/hello.wasm"; std::string TEST_WASM2 = "/mytest.wasm"; char *WASM_FILE_1; char *WASM_FILE_2; -std::vector running_mode_supportted = { Mode_Interp, +std::vector running_mode_supported = { Mode_Interp, #if WASM_ENABLE_FAST_JIT != 0 Mode_Fast_JIT, #endif @@ -76,7 +76,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam return true; fail: - if (!module) + if (module) wasm_runtime_unload(module); return false; @@ -101,11 +101,13 @@ class wasm_running_modes_test_suite : public testing::TestWithParam if (exec_env) wasm_runtime_destroy_exec_env(exec_env); if (module_inst) + wasm_runtime_deinstantiate(module_inst); + if (module) wasm_runtime_unload(module); return false; } - void destory_exec_env() + void destroy_exec_env() { wasm_runtime_destroy_exec_env(exec_env); wasm_runtime_deinstantiate(module_inst); @@ -139,7 +141,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam ASSERT_TRUE(ret); ASSERT_EQ(10, wasm_argv[0]); - destory_exec_env(); + destroy_exec_env(); } void run_wasm_complex(char *filename1, char *filename2, @@ -168,7 +170,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam ASSERT_TRUE(ret); ASSERT_EQ(10, wasm_argv[0]); - destory_exec_env(); + destroy_exec_env(); /* run wasm file 2 in running_mode */ ret = load_wasm_file(filename2); @@ -184,7 +186,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam ret = wasm_runtime_call_wasm(exec_env, main, 2, wasm_argv); ASSERT_TRUE(ret); - destory_exec_env(); + destroy_exec_env(); } public: @@ -246,7 +248,7 @@ TEST_F(wasm_running_modes_test_suite, wasm_runtime_is_running_mode_supported) // normal situation ASSERT_EQ(true, wasm_runtime_is_running_mode_supported( static_cast(Mode_Default))); - for (auto running_mode : running_mode_supportted) { + for (auto running_mode : running_mode_supported) { ASSERT_EQ(true, wasm_runtime_is_running_mode_supported(running_mode)); } @@ -264,7 +266,7 @@ TEST_F(wasm_running_modes_test_suite, wasm_runtime_set_default_running_mode) // normal situation: only set up ASSERT_EQ(true, wasm_runtime_set_default_running_mode( static_cast(Mode_Default))); - for (auto running_mode : running_mode_supportted) { + for (auto running_mode : running_mode_supported) { ASSERT_EQ(true, wasm_runtime_set_default_running_mode(running_mode)); } @@ -296,13 +298,13 @@ TEST_P(wasm_running_modes_test_suite, wasm_runtime_set_and_get_running_mode_complex) { RunningMode default_running_mode = GetParam(); - for (auto running_mode : running_mode_supportted) { + for (auto running_mode : running_mode_supported) { run_wasm_complex(WASM_FILE_1, WASM_FILE_2, default_running_mode, running_mode); } } INSTANTIATE_TEST_CASE_P(RunningMode, wasm_running_modes_test_suite, - testing::ValuesIn(running_mode_supportted)); + testing::ValuesIn(running_mode_supported)); -} \ No newline at end of file +} diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 8a72ae2016..f248c7cbb6 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -414,7 +414,7 @@ function setup_wabt() function compile_reference_interpreter() { - echo "compile the reference intepreter" + echo "compile the reference interpreter" pushd interpreter make if [ $? -ne 0 ] From 2372a472aa38fd87ad0b36ceee7d64e1e4853cd1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 27 Jun 2025 08:41:42 +0900 Subject: [PATCH 316/431] wasi-nn: make the host use the wasi_ephemeral_nn version of tensor_data (#4411) the motivations: * make the actual input size available to the backends. (currently the backends have to make a guess from shape/type.) * make the host logic look a bit similar to wasi_ephemeral_nn. this is a backend api/abi change. --- .../libraries/wasi-nn/include/wasi_nn_types.h | 2 +- .../wasi-nn/src/utils/wasi_nn_app_native.c | 17 +++++++++++------ core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 19 ++++++++++--------- .../libraries/wasi-nn/src/wasi_nn_llamacpp.c | 8 ++++---- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 8 ++++---- .../libraries/wasi-nn/src/wasi_nn_openvino.h | 4 ++-- .../libraries/wasi-nn/src/wasi_nn_private.h | 2 +- .../wasi-nn/src/wasi_nn_tensorflowlite.cpp | 18 +++++++++--------- .../wasi-nn/src/wasi_nn_tensorflowlite.hpp | 2 +- 9 files changed, 43 insertions(+), 37 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 d2e3f4caca..952fb65e28 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -99,7 +99,7 @@ typedef enum { // 4-byte f32 elements would have a data array of length 16). Naturally, this // representation requires some knowledge of how to lay out data in // memory--e.g., using row-major ordering--and could perhaps be improved. -#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 && defined(__wasm__) +#if !defined(__wasm__) || WASM_ENABLE_WASI_EPHEMERAL_NN != 0 typedef struct { uint8_t *buf; uint32_t size; diff --git a/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c b/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c index 6e91c949bf..4d56fed93e 100644 --- a/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c +++ b/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c @@ -99,7 +99,8 @@ graph_builder_array_app_native(wasm_module_inst_t instance, static wasi_nn_error tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements, - tensor_wasm *input_tensor_wasm, tensor_data *data) + tensor_wasm *input_tensor_wasm, void **data, + uint32_t *size) { #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #define data_size input_tensor_wasm->data_size @@ -113,8 +114,9 @@ tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements, NN_ERR_PRINTF("input_tensor_wasm->data_offset is invalid"); return invalid_argument; } - *data = (tensor_data)wasm_runtime_addr_app_to_native( + *data = wasm_runtime_addr_app_to_native( instance, (uint64)input_tensor_wasm->data_offset); + *size = data_size; return success; #undef data_size } @@ -188,16 +190,19 @@ tensor_app_native(wasm_module_inst_t instance, tensor_wasm *input_tensor_wasm, NN_DBG_PRINTF("Tensor type: %d", input_tensor_wasm->type); NN_DBG_PRINTF("Total number of elements: %d", total_elements); - tensor_data data = NULL; + void *data = NULL; + uint32_t datasize; if (success - != (res = tensor_data_app_native(instance, total_elements, - input_tensor_wasm, &data))) { + != (res = + tensor_data_app_native(instance, total_elements, + input_tensor_wasm, &data, &datasize))) { wasm_runtime_free(dimensions); return res; } input_tensor->type = input_tensor_wasm->type; input_tensor->dimensions = dimensions; - input_tensor->data = data; + input_tensor->data.buf = data; + input_tensor->data.size = datasize; return success; } diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 25d70e6a94..5c865c5be2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -720,12 +720,12 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx) #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 wasi_nn_error wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, - uint32_t index, tensor_data output_tensor, + uint32_t index, void *output_tensor, uint32_t output_tensor_len, uint32_t *output_tensor_size) #else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ wasi_nn_error wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, - uint32_t index, tensor_data output_tensor, + uint32_t index, void *output_tensor, uint32_t *output_tensor_size) #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ { @@ -753,16 +753,17 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, goto fail; } + tensor_data tensor = { + .buf = output_tensor, #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 + .size = output_tensor_len, +#else + .size = *output_tensor_size, +#endif + }; call_wasi_nn_func(wasi_nn_ctx->backend, get_output, res, - wasi_nn_ctx->backend_ctx, ctx, index, output_tensor, - &output_tensor_len); - *output_tensor_size = output_tensor_len; -#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ - call_wasi_nn_func(wasi_nn_ctx->backend, get_output, res, - wasi_nn_ctx->backend_ctx, ctx, index, output_tensor, + wasi_nn_ctx->backend_ctx, ctx, index, &tensor, output_tensor_size); -#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ fail: unlock_ctx(wasi_nn_ctx); return res; 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 ff31e3adb2..65ec83f8de 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -385,7 +385,7 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; // tensor->data is the prompt string. ends with \0 - char *prompt_text = (char *)wasi_nn_tensor->data; + char *prompt_text = (char *)wasi_nn_tensor->data.buf; #ifndef NDEBUG NN_DBG_PRINTF("--------------------------------------------------"); @@ -552,7 +552,7 @@ compute(void *ctx, graph_execution_context exec_ctx) __attribute__((visibility("default"))) wasi_nn_error get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, - tensor_data output_tensor, uint32_t *output_tensor_size) + tensor_data *output_tensor, uint32_t *output_tensor_size) { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; @@ -571,7 +571,7 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, printf("%s\n", output_metadata); } - memcpy(output_tensor, output_metadata, strlen(output_metadata)); + memcpy(output_tensor->buf, output_metadata, strlen(output_metadata)); *output_tensor_size = strlen(output_metadata); return success; } @@ -591,7 +591,7 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, printf("%s", buf); } - memcpy(output_tensor + end_pos, buf, strlen(buf)); + memcpy(output_tensor->buf + end_pos, buf, strlen(buf)); end_pos += strlen(buf); } 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 3c3b0ae6c2..8c62ad6890 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -402,7 +402,7 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, shape_info); CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(input_type, input_shape, - wasi_nn_tensor->data, + wasi_nn_tensor->data.buf, &input_tensor), ret); } @@ -441,7 +441,7 @@ compute(void *ctx, graph_execution_context exec_ctx) __attribute__((visibility("default"))) wasi_nn_error get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, - tensor_data output_tensor, uint32_t *output_tensor_size) + tensor_data *output_tensor, uint32_t *output_tensor_size) { OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; struct OpenVINOExecutionContext *exec; @@ -460,14 +460,14 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret); - if (byte_size > *output_tensor_size) { + if (byte_size > output_tensor->size) { ret = too_large; goto fail; } CHECK_OV_STATUS(ov_tensor_data(ov_tensor, &data), ret); - memcpy(output_tensor, data, byte_size); + memcpy(output_tensor->buf, data, byte_size); *output_tensor_size = (uint32_t)byte_size; diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h index ea03a226f9..0233568c00 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h @@ -24,7 +24,7 @@ compute(void *ctx, graph_execution_context exec_ctx); __attribute__((visibility("default"))) wasi_nn_error get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, - tensor_data output_tensor, uint32_t *output_tensor_size); + tensor_data *output_tensor, uint32_t *output_tensor_size); __attribute__((visibility("default"))) wasi_nn_error init_backend(void **ctx); @@ -32,4 +32,4 @@ init_backend(void **ctx); __attribute__((visibility("default"))) wasi_nn_error deinit_backend(void *ctx); -#endif /* WASI_NN_OPENVINO_HPP */ \ No newline at end of file +#endif /* WASI_NN_OPENVINO_HPP */ 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 a20ad1718c..466f2cef45 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h @@ -32,7 +32,7 @@ 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 *); + tensor_data *, uint32_t *); /* wasi-nn general APIs */ typedef wasi_nn_error (*BACKEND_INITIALIZE)(void **); typedef wasi_nn_error (*BACKEND_DEINITIALIZE)(void *); 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 c9064a5ec3..0ca323b70e 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -324,7 +324,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index, index); int size = model_tensor_size * sizeof(float); - bh_memcpy_s(it, size, input_tensor->data, size); + bh_memcpy_s(it, size, input_tensor->data.buf, size); } else { // TODO: Assuming uint8 quantized networks. TfLiteAffineQuantization *quant_info = @@ -342,7 +342,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index, NN_DBG_PRINTF("input tensor: (scale, offset) = (%f, %f)", scale, zero_point); - float *input_tensor_f = (float *)input_tensor->data; + float *input_tensor_f = (float *)input_tensor->data.buf; for (uint32_t i = 0; i < model_tensor_size; ++i) { it[i] = (uint8_t)(input_tensor_f[i] / scale + zero_point); } @@ -366,7 +366,7 @@ compute(void *tflite_ctx, graph_execution_context ctx) __attribute__((visibility("default"))) wasi_nn_error get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, - tensor_data output_tensor, uint32_t *output_tensor_size) + tensor_data *output_tensor, uint32_t *output_tensor_size) { TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx; @@ -392,7 +392,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, if (tensor->quantization.type == kTfLiteNoQuantization) { NN_DBG_PRINTF("No quantization information"); #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 - if (*output_tensor_size < tensor->bytes) { + if (output_tensor->size < tensor->bytes) { NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); return too_large; } @@ -401,12 +401,12 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, * for now, maintain the bug-to-bug compatibility with the old abi, * where the size here is the number of fp32, not bytes. */ - if (*output_tensor_size < tensor->bytes / sizeof(float)) { + if (output_tensor->size < tensor->bytes / sizeof(float)) { NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); return too_large; } #endif - bh_memcpy_s(output_tensor, *output_tensor_size, tensor->data.data, + bh_memcpy_s(output_tensor->buf, output_tensor->size, tensor->data.data, tensor->bytes); #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 *output_tensor_size = tensor->bytes; @@ -431,7 +431,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, model_tensor_size *= (uint32_t)tensor->dims->data[i]; #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 - if (*output_tensor_size / sizeof(float) < model_tensor_size) { + if (output_tensor->size / sizeof(float) < model_tensor_size) { NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); return too_large; } @@ -440,7 +440,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, * for now, maintain the bug-to-bug compatibility with the old abi, * where the size here is the number of fp32, not bytes. */ - if (*output_tensor_size < model_tensor_size) { + if (output_tensor->size < model_tensor_size) { NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); return too_large; } @@ -454,7 +454,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, NN_DBG_PRINTF("output tensor: (scale, offset) = (%f, %f)", scale, zero_point); - float *output_tensor_f = (float *)output_tensor; + float *output_tensor_f = (float *)output_tensor->buf; for (uint32_t i = 0; i < model_tensor_size; ++i) { output_tensor_f[i] = (ot[i] - zero_point) * scale; } diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp index d6e04ab0e1..4ded6e4074 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp @@ -32,7 +32,7 @@ compute(void *tflite_ctx, graph_execution_context ctx); __attribute__((visibility("default"))) wasi_nn_error get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, - tensor_data output_tensor, uint32_t *output_tensor_size); + tensor_data *output_tensor, uint32_t *output_tensor_size); __attribute__((visibility("default"))) wasi_nn_error init_backend(void **tflite_ctx); From d6876f1e9f1e974eeae9bd68ec1bc5f601ef5ec1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 27 Jun 2025 12:51:03 +0900 Subject: [PATCH 317/431] wasi_nn_llamacpp.c: fix buffer overruns in set_input (#4420) note: for some reasons, wasmedge seems to ignore type/dimensions for the input of ggml. some user code relies on it. cf. https://github.com/second-state/WasmEdge-WASINN-examples/issues/196 note: despite the comment in our code, the input doesn't seem nul-terminated. --- core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 65ec83f8de..4e5ca3bbb8 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -384,18 +384,18 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, tensor *wasi_nn_tensor) { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; - // tensor->data is the prompt string. ends with \0 + // tensor->data is the prompt string. char *prompt_text = (char *)wasi_nn_tensor->data.buf; + uint32_t prompt_text_len = wasi_nn_tensor->data.size; #ifndef NDEBUG NN_DBG_PRINTF("--------------------------------------------------"); - NN_DBG_PRINTF("prompt_text: %s", prompt_text); + NN_DBG_PRINTF("prompt_text: %.*s", (int)prompt_text_len, prompt_text); NN_DBG_PRINTF("--------------------------------------------------"); #endif // tokenize the prompt uint32_t n_token_max = llama_n_ctx(backend_ctx->ctx); - uint32_t prompt_text_len = strlen(prompt_text); if (backend_ctx->prompt == NULL) { backend_ctx->prompt = calloc(n_token_max, sizeof(llama_token)); From 8ed89e2ab22f4e4acd436bb401a9f3e9e900cf4f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 27 Jun 2025 12:55:08 +0900 Subject: [PATCH 318/431] wasi_nn_llamacpp.c: remove an unused variable (#4415) --- core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c | 2 -- 1 file changed, 2 deletions(-) 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 4e5ca3bbb8..572a5bf336 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -480,7 +480,6 @@ compute(void *ctx, graph_execution_context exec_ctx) // main loop int32_t n_cur = batch.n_tokens; - int n_decode = 0; int32_t n_vocab = llama_n_vocab(backend_ctx->model); llama_token_data *candidates = NULL; @@ -531,7 +530,6 @@ compute(void *ctx, graph_execution_context exec_ctx) // push this new token for next evaluation llama_batch_add(&batch, new_token_id, n_cur, seq_ids, sizeof(seq_ids) / sizeof(seq_ids[0]), true); - n_decode++; n_cur++; if (llama_decode(backend_ctx->ctx, batch) != 0) { From 0641dd150657ab96a687beac4650466e22de9e2e Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 27 Jun 2025 11:55:32 +0800 Subject: [PATCH 319/431] Fix few shadow warnings (#4409) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - declaration of ‘memidx’ shadows a previous local - declaration of ‘count’ shadows a previous local --- core/iwasm/interpreter/wasm_interp_classic.c | 2 +- core/iwasm/interpreter/wasm_loader.c | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 1e98b0fa91..07cf6c1ffd 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -4088,7 +4088,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, case WASM_OP_STRING_ENCODE_LOSSY_UTF8_ARRAY: case WASM_OP_STRING_ENCODE_WTF8_ARRAY: { - uint32 start, array_len, count; + uint32 start, array_len; int32 bytes_written; EncodingFlag flag = WTF8; WASMArrayType *array_type; diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 907db9226f..4bdd8bc7fc 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -15024,8 +15024,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_STRING_NEW_LOSSY_UTF8: case WASM_OP_STRING_NEW_WTF8: { - uint32 memidx; - #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; #endif @@ -15037,7 +15035,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, POP_I32(); POP_I32(); PUSH_REF(REF_TYPE_STRINGREF); - (void)memidx; break; } case WASM_OP_STRING_CONST: @@ -15065,8 +15062,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_STRING_ENCODE_LOSSY_UTF8: case WASM_OP_STRING_ENCODE_WTF8: { - uint32 memidx; - #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; #endif @@ -15078,7 +15073,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, POP_I32(); POP_STRINGREF(); PUSH_I32(); - (void)memidx; break; } case WASM_OP_STRING_CONCAT: @@ -15119,8 +15113,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_STRINGVIEW_WTF8_ENCODE_LOSSY_UTF8: case WASM_OP_STRINGVIEW_WTF8_ENCODE_WTF8: { - uint32 memidx; - #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; #endif @@ -15135,7 +15127,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, POP_REF(REF_TYPE_STRINGVIEWWTF8); PUSH_I32(); PUSH_I32(); - (void)memidx; break; } case WASM_OP_STRINGVIEW_WTF8_SLICE: @@ -15167,8 +15158,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_STRINGVIEW_WTF16_ENCODE: { - uint32 memidx; - #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; #endif @@ -15182,7 +15171,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, POP_I32(); POP_REF(REF_TYPE_STRINGVIEWWTF16); PUSH_I32(); - (void)memidx; break; } case WASM_OP_STRINGVIEW_WTF16_SLICE: From 18d4227ab6593bb1870aac025d351cce9e3c1041 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 27 Jun 2025 13:28:46 +0900 Subject: [PATCH 320/431] CI: build wamr-wasi-extensions (#4394) * wamr-wasi-extensions: separate test scripts also, allow to specify the prefix directory. for the convenience of the CI. * CI: build wamr-wasi-extensions fragments are copied from compilation_on_macos.yml. (thus intel copyright notice) --- .github/workflows/wamr_wasi_extensions.yml | 57 ++++++++++++++++++++++ wamr-wasi-extensions/build_libs.sh | 15 ++++++ wamr-wasi-extensions/build_samples.sh | 33 +++++++++++++ wamr-wasi-extensions/test.sh | 34 ++----------- 4 files changed, 108 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/wamr_wasi_extensions.yml create mode 100755 wamr-wasi-extensions/build_libs.sh create mode 100755 wamr-wasi-extensions/build_samples.sh diff --git a/.github/workflows/wamr_wasi_extensions.yml b/.github/workflows/wamr_wasi_extensions.yml new file mode 100644 index 0000000000..e9d10fe93c --- /dev/null +++ b/.github/workflows/wamr_wasi_extensions.yml @@ -0,0 +1,57 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +name: wamr_wasi_extensions + +on: + pull_request: + types: + - opened + - synchronize + paths: + - ".github/workflows/wamr_wasi_extensions.yml" + - "wamr_wasi_extensios/**" + - "core/iwasm/libraries/wasi-nn/include/**" + - "core/iwasm/libraries/lib-socket/**" + # allow to be triggered manually + workflow_dispatch: + +# Cancel any in-flight jobs for the same PR/branch so there's only one active +# at a time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_wamr_wasi_extensions: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, macos-13, macos-14] + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} + + - name: Build wamr-wasi-extensions + run: | + mkdir dist + ./build_libs.sh $(pwd)/dist/wamr-wasi-extensions + working-directory: wamr-wasi-extensions + + - name: Build wamr-wasi-extensions samples + run: | + ./build_samples.sh $(pwd)/dist/wamr-wasi-extensions + working-directory: wamr-wasi-extensions + + - name: Upload artifacts + if: matrix.os == 'macos-14' + uses: actions/upload-artifact@v4 + with: + name: wamr-wasi-extensions + path: wamr-wasi-extensions/dist + retention-days: 10 diff --git a/wamr-wasi-extensions/build_libs.sh b/wamr-wasi-extensions/build_libs.sh new file mode 100755 index 0000000000..97f2fe1049 --- /dev/null +++ b/wamr-wasi-extensions/build_libs.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set -e + +PREFIX=${1:-/tmp/wamr} +WASI_SDK=${WASI_SDK:-/opt/wasi-sdk} + +cmake -B build-lib \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_INSTALL_PREFIX=${PREFIX} \ +. +cmake --build build-lib -t install diff --git a/wamr-wasi-extensions/build_samples.sh b/wamr-wasi-extensions/build_samples.sh new file mode 100755 index 0000000000..5dfeeabf2f --- /dev/null +++ b/wamr-wasi-extensions/build_samples.sh @@ -0,0 +1,33 @@ +#! /bin/sh + +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set -e + +PREFIX=${1:-/tmp/wamr} +WASI_SDK=${WASI_SDK:-/opt/wasi-sdk} + +cmake -B build-app-nn \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/nn +cmake --build build-app-nn + +cmake -B build-app-nn-cli \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/nn-cli +cmake --build build-app-nn-cli + +cmake -B build-app-socket-nslookup \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/socket-nslookup +cmake --build build-app-socket-nslookup + +cmake -B build-app-socket-tcp-udp \ +-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ +-DCMAKE_PREFIX_PATH=${PREFIX} \ +samples/socket-tcp-udp +cmake --build build-app-socket-tcp-udp diff --git a/wamr-wasi-extensions/test.sh b/wamr-wasi-extensions/test.sh index e485cf48c7..1d366dfe9b 100755 --- a/wamr-wasi-extensions/test.sh +++ b/wamr-wasi-extensions/test.sh @@ -5,35 +5,7 @@ set -e -PREFIX=/tmp/wamr -WASI_SDK=${WASI_SDK:-/opt/wasi-sdk} +PREFIX=${1:-/tmp/wamr} -cmake -B build-lib \ --DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ --DCMAKE_INSTALL_PREFIX=${PREFIX} \ -. -cmake --build build-lib -t install - -cmake -B build-app-nn \ --DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ --DCMAKE_PREFIX_PATH=${PREFIX} \ -samples/nn -cmake --build build-app-nn - -cmake -B build-app-nn-cli \ --DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk.cmake \ --DCMAKE_PREFIX_PATH=${PREFIX} \ -samples/nn-cli -cmake --build build-app-nn-cli - -cmake -B build-app-socket-nslookup \ --DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ --DCMAKE_PREFIX_PATH=${PREFIX} \ -samples/socket-nslookup -cmake --build build-app-socket-nslookup - -cmake -B build-app-socket-tcp-udp \ --DCMAKE_TOOLCHAIN_FILE=${WASI_SDK}/share/cmake/wasi-sdk-pthread.cmake \ --DCMAKE_PREFIX_PATH=${PREFIX} \ -samples/socket-tcp-udp -cmake --build build-app-socket-tcp-udp +./build_libs.sh ${PREFIX} +./build_samples.sh ${PREFIX} From 7a6a6a39e9765fbd250b7c1e09ff9bfdd1608519 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 30 Jun 2025 13:57:44 +0900 Subject: [PATCH 321/431] wasi_nn_openvino.c: fix a debug build (#4416) after "wasi_nn_openvino.c: implement multiple models per instance" change. (https://github.com/bytecodealliance/wasm-micro-runtime/pull/4380) --- 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 8c62ad6890..ae3a8572ca 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -287,7 +287,7 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding, graph->weights_tensor, &graph->model), ret); #ifndef NDEBUG - print_model_input_output_info(ov_ctx->model); + print_model_input_output_info(graph->model); #endif CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, graph->model, "CPU", 0, From 0127eafbe56284836bc97aefcce1dd628545a107 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:57:57 +0800 Subject: [PATCH 322/431] loader: fix a potential overflow issue (#4427) --- core/iwasm/interpreter/wasm_loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 4bdd8bc7fc..5dd9f05207 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -2042,9 +2042,9 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, "recursive type count too large"); return false; } - module->type_count += rec_count - 1; new_total_size = - sizeof(WASMFuncType *) * (uint64)module->type_count; + sizeof(WASMFuncType *) + * (uint64)(module->type_count + rec_count - 1); if (new_total_size > UINT32_MAX) { set_error_buf(error_buf, error_buf_size, "allocate memory failed"); @@ -2052,6 +2052,7 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, } MEM_REALLOC(module->types, (uint32)total_size, (uint32)new_total_size); + module->type_count += rec_count - 1; total_size = new_total_size; } From 4fbb372f1570b3a058a8a98d4c7449a61a9ad500 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 30 Jun 2025 13:58:20 +0900 Subject: [PATCH 323/431] CI: revert SGX retry attempts (#4421) * Revert "Improve spec test execution by adding retry logic for transient errors (#4393)" This reverts commit 64cafaff1eee1942154867e4c4088dd2bfb70284. * Revert "Add error handling for sgx ci (#4222)" This reverts commit 8ad47897d1f5579a3c9d75e4d7d234474fc54bbd. --- .github/workflows/compilation_on_sgx.yml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index 3033c270e3..541f7a2840 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -288,24 +288,8 @@ jobs: sudo swapon /swapfile sudo swapon --show - - name: run spec tests with retry - id: run_spec_tests - uses: nick-fields/retry@v3 - with: - command: | - cd ./tests/wamr-test-suites - source /opt/intel/sgxsdk/environment - ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} - max_attempts: 3 - retry_on: error - shell: bash - timeout_minutes: 10 - - - name: print test results + - name: run spec tests run: | - echo "Test results:" - echo "${{ steps.run_spec_tests.outputs.stdout }}" - echo "${{ steps.run_spec_tests.outputs.stderr }}" - echo "Exit code: ${{ steps.run_spec_tests.outputs.exit_code }}" - echo "Exit error: ${{ steps.run_spec_tests.outputs.exit_error }}" - shell: bash + source /opt/intel/sgxsdk/environment + ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} + working-directory: ./tests/wamr-test-suites From cb233ec042489189b95b70fbf02f965d090dca48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:07:48 +0800 Subject: [PATCH 324/431] build(deps): Bump github/codeql-action from 3.29.0 to 3.29.1 (#4436) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.0 to 3.29.1. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.29.0...v3.29.1) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.29.1 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 9c33097213..8c2dfeff8c 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.29.0 + uses: github/codeql-action/init@v3.29.1 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.29.0 + uses: github/codeql-action/analyze@v3.29.1 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.29.0 + uses: github/codeql-action/upload-sarif@v3.29.1 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 827b300f1d..a6c1a5a4f9 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@2847b7f7ab9f48fc49eca90a53fff6007285f399 + uses: github/codeql-action/upload-sarif@4c57370d0304fbff638216539f81d9163f77712a with: sarif_file: results.sarif From 430cc5e5efd7a1d7191e6cab78f42455f6cd4df5 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 1 Jul 2025 10:10:11 +0800 Subject: [PATCH 325/431] Refactor AOTObjectData definition to use a forward declaration (#4428) > core/iwasm/compilation/aot_emit_aot_file.c:85:3: error: redefinition of typedef 'AOTObjectData' is a C11 feature --- core/iwasm/compilation/aot_emit_aot_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index b41399acb7..a1c47bfac5 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -48,7 +48,7 @@ typedef struct AOTSymbolList { } AOTSymbolList; /* AOT object data */ -typedef struct AOTObjectData { +struct AOTObjectData { AOTCompContext *comp_ctx; LLVMMemoryBufferRef mem_buf; @@ -82,7 +82,7 @@ typedef struct AOTObjectData { const char *stack_sizes_section_name; uint32 stack_sizes_offset; uint32 *stack_sizes; -} AOTObjectData; +}; #if 0 static void dump_buf(uint8 *buf, uint32 size, char *title) From 38fe056cc6f2473b538eef5b51dbc3d64d94f70a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 1 Jul 2025 11:37:12 +0900 Subject: [PATCH 326/431] wasi-nn: reduce code duplication a bit (#4433) --- .../{wasi_nn_openvino.h => wasi_nn_backend.h} | 21 +++++++-- .../libraries/wasi-nn/src/wasi_nn_llamacpp.c | 2 +- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 3 +- .../wasi-nn/src/wasi_nn_tensorflowlite.cpp | 3 +- .../wasi-nn/src/wasi_nn_tensorflowlite.hpp | 47 ------------------- 5 files changed, 21 insertions(+), 55 deletions(-) rename core/iwasm/libraries/wasi-nn/src/{wasi_nn_openvino.h => wasi_nn_backend.h} (68%) delete mode 100644 core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h b/core/iwasm/libraries/wasi-nn/src/wasi_nn_backend.h similarity index 68% rename from core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h rename to core/iwasm/libraries/wasi-nn/src/wasi_nn_backend.h index 0233568c00..8cd03f1214 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_backend.h @@ -3,15 +3,26 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -#ifndef WASI_NN_OPENVINO_HPP -#define WASI_NN_OPENVINO_HPP +#ifndef WASI_NN_BACKEND_H +#define WASI_NN_BACKEND_H #include "wasi_nn_types.h" +#ifdef __cplusplus +extern "C" { +#endif + __attribute__((visibility("default"))) wasi_nn_error load(void *ctx, graph_builder_array *builder, graph_encoding encoding, execution_target target, graph *g); +__attribute__((visibility("default"))) wasi_nn_error +load_by_name(void *tflite_ctx, const char *name, uint32_t namelen, graph *g); + +__attribute__((visibility("default"))) wasi_nn_error +load_by_name_with_config(void *ctx, const char *name, uint32_t namelen, + const char *config, uint32_t config_len, graph *g); + __attribute__((visibility("default"))) wasi_nn_error init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx); @@ -32,4 +43,8 @@ init_backend(void **ctx); __attribute__((visibility("default"))) wasi_nn_error deinit_backend(void *ctx); -#endif /* WASI_NN_OPENVINO_HPP */ +#ifdef __cplusplus +} +#endif + +#endif /* WASI_NN_BACKEND_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 572a5bf336..5cad663dd7 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -5,7 +5,7 @@ #include -#include "wasi_nn_types.h" +#include "wasi_nn_backend.h" #include "utils/logger.h" #include "llama.h" #include "ggml.h" 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 ae3a8572ca..e6c5f33cba 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -3,8 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -#include "wasi_nn_types.h" -#include "wasi_nn_openvino.h" +#include "wasi_nn_backend.h" #include "utils/logger.h" #include "bh_platform.h" 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 0ca323b70e..819bd52aff 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -3,11 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -#include "wasi_nn_tensorflowlite.hpp" #include "utils/logger.h" #include "bh_platform.h" -#include "wasi_nn_types.h" +#include "wasi_nn_backend.h" #include "wasm_export.h" #include diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp deleted file mode 100644 index 4ded6e4074..0000000000 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#ifndef WASI_NN_TENSORFLOWLITE_HPP -#define WASI_NN_TENSORFLOWLITE_HPP - -#include "wasi_nn_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -__attribute__((visibility("default"))) wasi_nn_error -load(void *tflite_ctx, graph_builder_array *builder, graph_encoding encoding, - execution_target target, graph *g); - -__attribute__((visibility("default"))) wasi_nn_error -load_by_name(void *tflite_ctx, const char *filename, uint32_t filename_len, - graph *g); - -__attribute__((visibility("default"))) wasi_nn_error -init_execution_context(void *tflite_ctx, graph g, graph_execution_context *ctx); - -__attribute__((visibility("default"))) wasi_nn_error -set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index, - tensor *input_tensor); - -__attribute__((visibility("default"))) wasi_nn_error -compute(void *tflite_ctx, graph_execution_context ctx); - -__attribute__((visibility("default"))) wasi_nn_error -get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, - tensor_data *output_tensor, uint32_t *output_tensor_size); - -__attribute__((visibility("default"))) wasi_nn_error -init_backend(void **tflite_ctx); - -__attribute__((visibility("default"))) wasi_nn_error -deinit_backend(void *tflite_ctx); - -#ifdef __cplusplus -} -#endif - -#endif From 8949797c844bda6690c80be0c49947ffce6e56ef Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Tue, 1 Jul 2025 10:44:53 +0800 Subject: [PATCH 327/431] Improve run.py of regression (#4417) * Improve run.py of regression 1. Fix script interruption on case failure 2. improve statistics logic 3. enable select specific issue ids --- tests/regression/ba-issues/README.md | 41 ++++++++- tests/regression/ba-issues/run.py | 127 +++++++++++++++++++-------- 2 files changed, 126 insertions(+), 42 deletions(-) diff --git a/tests/regression/ba-issues/README.md b/tests/regression/ba-issues/README.md index dd5c3b3c51..ed423da411 100644 --- a/tests/regression/ba-issues/README.md +++ b/tests/regression/ba-issues/README.md @@ -218,22 +218,57 @@ simply run `run.py` ./run.py ``` +Specify a specific issue with option `--issues`/`-i` + +```shell +./run.py --issues 2833 # test 1 issue #2833 +./run.py -i 2833,2834,2835 # test 3 issues #2833 #2834 #2835 +``` + If everything went well, you should see similarly output in your command line output ```shell -Finish testing, 22/22 of test cases passed, no more issues should further test +==== Test results ==== + Total: 22 + Passed: 22 + Failed: 0 + Left issues in folder: no more + Cases in JSON but not found in folder: no more ``` If you add the test case under directory `issues` but forget to add the running config in json file, the output can be something like ```shell -Finish testing, 21/21 of test cases passed, {2945} issue(s) should further test +==== Test results ==== + Total: 21 + Passed: 21 + Failed: 0 + missed: 0 + Left issues in folder: #3022 + Cases in JSON but not found in folder: no more +``` + +If you add the test case in `running_config.json` but used the wrong id or forget to add the test case under directory `issues`, the output can be someting like + +```shell +==== Test results ==== + Total: 21 + Passed: 21 + Failed: 0 + missed: 0 + Left issues in folder: #2855 + Cases in JSON but not found in folder: #12345 ``` If some test case are failing, then it will be something like ```shell -Finish testing, 21/22 of test cases passed, no more issue(s) should further test +==== Test results ==== + Total: 22 + Passed: 21 + Failed: 1 + Left issues in folder: no more + Cases in JSON but not found in folder: no more ``` And a log file named `issues_tests.log` will be generated and inside it will display the details of the failing cases, for example: diff --git a/tests/regression/ba-issues/run.py b/tests/regression/ba-issues/run.py index 7f26738d12..5a57bfcf6f 100755 --- a/tests/regression/ba-issues/run.py +++ b/tests/regression/ba-issues/run.py @@ -10,7 +10,9 @@ import subprocess import glob import re -from typing import Dict +import argparse + +from typing import Dict, Optional, List WORK_DIR = os.getcwd() TEST_WASM_COMMAND = ( @@ -45,7 +47,12 @@ def dump_error_log(failing_issue_id, command_lists, exit_code_cmp, stdout_cmp): ) -def get_issue_ids_should_test(): +def get_issue_ids_should_test(selected_ids: Optional[List[int]] = None): + """Find all issue IDs that should be tested in folder issues.""" + # If specific issue IDs are provided, return them as a set + if selected_ids: + return set(selected_ids) + # Define the path pattern path_pattern = "issues/issue-*" @@ -60,8 +67,8 @@ def get_issue_ids_should_test(): # Extract the issue number using regular expression match = re.search(pattern, dir_path) if match: - issue_number = match.group(1) - issue_numbers.add(int(issue_number)) + issue_number = int(match.group(1)) + issue_numbers.add(issue_number) # Print the set of issue numbers return issue_numbers @@ -77,10 +84,10 @@ def get_and_check(d, key, default=None, nullable=False): def run_and_compare_results( - passed_ids, failed_ids, issue_id, cmd, description, ret_code, stdout_content -): + issue_id, cmd, description, ret_code, stdout_content +) -> bool: print(f"####################################") - print(f"test BA issue #{issue_id} `{description}`: {cmd}") + print(f"test BA issue #{issue_id} `{description}`...") command_list = cmd.split() result = subprocess.run( command_list, @@ -95,19 +102,21 @@ def run_and_compare_results( exit_code_cmp = f"exit code (actual, expected) : {actual_exit_code, ret_code}" stdout_cmp = f"stdout (actual, expected) : {actual_output, stdout_content}" - print(exit_code_cmp) - print(stdout_cmp) if actual_exit_code == ret_code and ( actual_output == stdout_content - or (stdout_content == "Compile success" - and actual_output.find(stdout_content) != -1) + or ( + stdout_content == "Compile success" + and actual_output.find(stdout_content) != -1 + ) or (len(stdout_content) > 30 and actual_output.find(stdout_content) != -1) ): - passed_ids.add(issue_id) print("== PASS ==") + return True else: - failed_ids.add(issue_id) + print(cmd) + print(exit_code_cmp) + print(stdout_cmp) print(f"== FAILED: {issue_id} ==") dump_error_log( issue_id, @@ -115,15 +124,11 @@ def run_and_compare_results( exit_code_cmp, stdout_cmp, ) + return False - print("") - -def run_issue_test_wamrc( - passed_ids, failed_ids, issue_id, compile_options, stdout_only_cmp_last_line=False -): +def run_issue_test_wamrc(issue_id, compile_options): compiler = get_and_check(compile_options, "compiler") - only_compile = get_and_check(compile_options, "only compile") in_file = get_and_check(compile_options, "in file") out_file = get_and_check(compile_options, "out file") options = get_and_check(compile_options, "options") @@ -145,14 +150,10 @@ def run_issue_test_wamrc( compiler=compiler, options=options, out_file=out_file_path, in_file=in_file_path ) - run_and_compare_results( - passed_ids, failed_ids, issue_id, cmd, description, ret_code, stdout_content - ) - - return only_compile + return run_and_compare_results(issue_id, cmd, description, ret_code, stdout_content) -def run_issue_test_iwasm(passed_ids, failed_ids, issue_id, test_case): +def run_issue_test_iwasm(issue_id, test_case) -> bool: runtime = get_and_check(test_case, "runtime") mode = get_and_check(test_case, "mode") file = get_and_check(test_case, "file") @@ -194,17 +195,19 @@ def run_issue_test_iwasm(passed_ids, failed_ids, issue_id, test_case): argument=argument, ) - run_and_compare_results( - passed_ids, failed_ids, issue_id, cmd, description, ret_code, stdout_content - ) + return run_and_compare_results(issue_id, cmd, description, ret_code, stdout_content) -def process_and_run_test_cases(data: Dict[str, Dict]): - issue_ids_should_test = get_issue_ids_should_test() +def process_and_run_test_cases( + data: Dict[str, Dict], selected_ids: Optional[List[int]] = None +): + issue_ids_should_test = get_issue_ids_should_test(selected_ids) passed_ids = set() failed_ids = set() + json_only_ids = set() + # Iterate through each test case in the json data for test_case in data.get("test cases", []): is_deprecated = get_and_check(test_case, "deprecated") issue_ids = get_and_check(test_case, "ids", default=[]) @@ -214,33 +217,79 @@ def process_and_run_test_cases(data: Dict[str, Dict]): continue compile_options = get_and_check(test_case, "compile_options", nullable=True) + for issue_id in issue_ids: + if issue_id not in issue_ids_should_test: + json_only_ids.add(issue_id) + continue + + # cross out the this issue_id in the should test set + issue_ids_should_test.remove(issue_id) + only_compile = False + # if this issue needs to test wamrc to compile the test case first if compile_options: only_compile = compile_options["only compile"] - run_issue_test_wamrc(passed_ids, failed_ids, issue_id, compile_options) + compile_res = run_issue_test_wamrc(issue_id, compile_options) + if only_compile: + if compile_res: + passed_ids.add(issue_id) + else: + failed_ids.add(issue_id) + continue + else: + # if compile success, then continue to test iwasm + if not compile_res: + failed_ids.add(issue_id) + continue # if this issue requires to test iwasm to run the test case if not only_compile: - run_issue_test_iwasm(passed_ids, failed_ids, issue_id, test_case) - - # cross out the this issue_id in the should test set - issue_ids_should_test.remove(issue_id) + if run_issue_test_iwasm(issue_id, test_case): + passed_ids.add(issue_id) + else: + failed_ids.add(issue_id) total = len(passed_ids) + len(failed_ids) passed = len(passed_ids) failed = len(failed_ids) - issue_ids_should_test = ( - issue_ids_should_test if issue_ids_should_test else "no more" + + format_issue_ids_should_test = ( + " ".join(f"#{x}" for x in issue_ids_should_test) + if issue_ids_should_test + else "no more" + ) + format_json_only_ids = ( + " ".join(f"#{x}" for x in json_only_ids) if json_only_ids else "no more" ) + + print(f"####################################") print(f"==== Test results ====") - print(f" Total: {total}") + print(f" Total: {total}") print(f" Passed: {passed}") print(f" Failed: {failed}") + if not selected_ids: + print(f" Left issues in folder: {format_issue_ids_should_test}") + print(f" Cases in JSON but not found in folder: {format_json_only_ids}") + else: + print(f" Issues not found in folder: {format_issue_ids_should_test}") def main(): + parser = argparse.ArgumentParser(description="Run BA issue tests.") + parser.add_argument( + "-i", + "--issues", + type=str, + help="Comma separated list of issue ids to run, e.g. 1,2,3. Default: all.", + ) + args = parser.parse_args() + + selected_ids = None + if args.issues: + selected_ids = [int(x) for x in args.issues.split(",") if x.strip().isdigit()] + # Path to the JSON file file_path = "running_config.json" @@ -256,7 +305,7 @@ def main(): os.remove(LOG_FILE) # Process the data - process_and_run_test_cases(data) + process_and_run_test_cases(data, selected_ids) if __name__ == "__main__": From c7148a6823c85ecb2f16cdc9e87518b4093a5434 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 1 Jul 2025 13:39:30 +0800 Subject: [PATCH 328/431] Fix potential integer overflow issues (#4429) It is reported as "Multiplication result converted to larger type". And "Multiplication result may overflow 'Type A' before it is converted to 'Type B'." Type A is a larger type than Type B. Since the conversion applies after the multiplication, arithmetic overflow may still occur. > The rule flags every multiplication of two non-constant integer expressions > that is (explicitly or implicitly) converted to a larger integer type. The > conversion is an indication that the expression would produce a result that > would be too large to fit in the smaller integer type. --- core/iwasm/aot/aot_runtime.c | 2 +- core/iwasm/compilation/aot_emit_aot_file.c | 4 ++-- core/iwasm/compilation/aot_emit_function.c | 3 ++- core/iwasm/interpreter/wasm_runtime.c | 2 +- core/iwasm/libraries/thread-mgr/thread_manager.c | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index f93e03dac7..6c14036801 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -3639,7 +3639,7 @@ aot_get_module_inst_mem_consumption(const AOTModuleInstance *module_inst, for (i = 0; i < module_inst->memory_count; i++) { AOTMemoryInstance *mem_inst = module_inst->memories[i]; mem_conspn->memories_size += - mem_inst->num_bytes_per_page * mem_inst->cur_page_count; + (uint64)mem_inst->num_bytes_per_page * mem_inst->cur_page_count; mem_conspn->app_heap_size = mem_inst->heap_data_end - mem_inst->heap_data; /* size of app heap structure */ diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index a1c47bfac5..7d0654b783 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -302,8 +302,8 @@ get_init_expr_size(const AOTCompContext *comp_ctx, const AOTCompData *comp_data, /* array_elem_type + type_index + len + elems */ size += sizeof(uint32) * 3 - + wasm_value_type_size_internal(array_type->elem_type, - comp_ctx->pointer_size) + + (uint64)wasm_value_type_size_internal( + array_type->elem_type, comp_ctx->pointer_size) * value_count; break; } diff --git a/core/iwasm/compilation/aot_emit_function.c b/core/iwasm/compilation/aot_emit_function.c index d22c1d5dd2..a1bc46332c 100644 --- a/core/iwasm/compilation/aot_emit_function.c +++ b/core/iwasm/compilation/aot_emit_function.c @@ -347,7 +347,8 @@ call_aot_invoke_c_api_native(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, /* Get &c_api_func_imports[func_idx], note size of CApiFuncImport is pointer_size * 3 */ - offset = I32_CONST((comp_ctx->pointer_size * 3) * import_func_idx); + offset = I32_CONST((unsigned long long)comp_ctx->pointer_size * 3 + * import_func_idx); CHECK_LLVM_CONST(offset); c_api_func_import = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_func_imports, diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 78af146abf..42178c594d 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4161,7 +4161,7 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, sizeof(WASMMemoryInstance *) * module_inst->memory_count; for (i = 0; i < module_inst->memory_count; i++) { WASMMemoryInstance *memory = module_inst->memories[i]; - size = memory->num_bytes_per_page * memory->cur_page_count; + size = (uint64)memory->num_bytes_per_page * memory->cur_page_count; mem_conspn->memories_size += size; mem_conspn->app_heap_size += memory->heap_data_end - memory->heap_data; /* size of app heap structure */ diff --git a/core/iwasm/libraries/thread-mgr/thread_manager.c b/core/iwasm/libraries/thread-mgr/thread_manager.c index 55e0526c3b..8f3a6317ba 100644 --- a/core/iwasm/libraries/thread-mgr/thread_manager.c +++ b/core/iwasm/libraries/thread-mgr/thread_manager.c @@ -301,7 +301,8 @@ wasm_cluster_create(WASMExecEnv *exec_env) aux_stack_start -= cluster->stack_size; for (i = 0; i < cluster_max_thread_num; i++) { - cluster->stack_tops[i] = aux_stack_start - cluster->stack_size * i; + cluster->stack_tops[i] = + aux_stack_start - (uint64)cluster->stack_size * i; } } #endif From ebf1404ad187926d75b38faaf3b419193486e030 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 1 Jul 2025 20:19:36 +0900 Subject: [PATCH 329/431] wasi_nn_openvino.c: avoid self-assignment warning (#4434) --- 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 e6c5f33cba..4ddc519101 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -143,7 +143,7 @@ print_model_input_output_info(ov_model_t *model) output_port = NULL; } - ov_error = ov_error; + (void)ov_error; fail: if (friendly_name) ov_free(friendly_name); From da6019f74947a6fd472ab6d2659904433d9a7eb8 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 1 Jul 2025 20:31:00 +0900 Subject: [PATCH 330/431] wasi_nn_llamacpp.c: reject invalid graph and execution context (#4422) * return valid graph and execution context instead of using stack garbage. (always 0 for now because we don't implement multiple graph/context for this backend.) * validate user-given graph and execution context values. reject invalid ones. --- .../libraries/wasi-nn/src/wasi_nn_llamacpp.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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 5cad663dd7..ce72afa74d 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -305,6 +305,11 @@ __load_by_name_with_configuration(void *ctx, const char *filename, graph *g) { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; + if (backend_ctx->model != NULL) { + // we only implement a single graph + return unsupported_operation; + } + // make sure backend_ctx->config is initialized struct llama_model_params model_params = @@ -323,6 +328,7 @@ __load_by_name_with_configuration(void *ctx, const char *filename, graph *g) #endif backend_ctx->model = model; + *g = 0; return success; } @@ -363,6 +369,16 @@ init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx) { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; + if (g != 0 || backend_ctx->model == NULL) { + // we only implement a single graph + return runtime_error; + } + + if (backend_ctx->ctx != NULL) { + // we only implement a single context + return unsupported_operation; + } + struct llama_context_params ctx_params = llama_context_params_from_wasi_nn_llama_config(&backend_ctx->config); struct llama_context *llama_ctx = @@ -373,6 +389,7 @@ init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx) } backend_ctx->ctx = llama_ctx; + *exec_ctx = 0; NN_INFO_PRINTF("n_predict = %d, n_ctx = %d", backend_ctx->config.n_predict, llama_n_ctx(backend_ctx->ctx)); @@ -384,6 +401,12 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, tensor *wasi_nn_tensor) { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; + + if (exec_ctx != 0 || backend_ctx->ctx == NULL) { + // we only implement a single context + return runtime_error; + } + // tensor->data is the prompt string. char *prompt_text = (char *)wasi_nn_tensor->data.buf; uint32_t prompt_text_len = wasi_nn_tensor->data.size; @@ -433,6 +456,11 @@ compute(void *ctx, graph_execution_context exec_ctx) struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; wasi_nn_error ret = runtime_error; + if (exec_ctx != 0 || backend_ctx->ctx == NULL) { + // we only implement a single context + return runtime_error; + } + // reset the generation buffer if (backend_ctx->generation == NULL) { backend_ctx->generation = @@ -554,6 +582,11 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, { struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; + if (exec_ctx != 0 || backend_ctx->ctx == NULL) { + // we only implement a single context + return runtime_error; + } + // Compatibility with WasmEdge if (index > 1) { NN_ERR_PRINTF("Invalid output index %d", index); From d598c0d0d316ca1fe4c32293686ff64e42aeabc7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 1 Jul 2025 20:32:01 +0900 Subject: [PATCH 331/431] CI: add wamr_wasi_extensions to the release assets (#4425) you can find an example of the release asset at: https://github.com/yamt/wasm-micro-runtime/releases/download/WAMR-2.3.999/wamr-wasi-extensions-2.3.999.zip note: this is a static library for wasm32-wasi. no need to provide per host OS (macOS, ubuntu, etc) binaries. --- .../workflows/build_wamr_wasi_extensions.yml | 57 +++++++++++++++++++ .github/workflows/release_process.yml | 9 +++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/build_wamr_wasi_extensions.yml diff --git a/.github/workflows/build_wamr_wasi_extensions.yml b/.github/workflows/build_wamr_wasi_extensions.yml new file mode 100644 index 0000000000..5412d794d1 --- /dev/null +++ b/.github/workflows/build_wamr_wasi_extensions.yml @@ -0,0 +1,57 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +name: build wamr_wasi_extensions release + +on: + workflow_call: + inputs: + upload_url: + description: upload binary assets to the URL of release + type: string + required: false + ver_num: + description: a semantic version number. it is required when `release` is true. + type: string + required: false + +permissions: + contents: read + +jobs: + build_wamr_wasi_extensions: + runs-on: ${{ matrix.os }} + permissions: + contents: write # for uploading release artifacts + strategy: + matrix: + os: [ubuntu-22.04] + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} + + - name: Build wamr-wasi-extensions + run: | + mkdir dist + ./build_libs.sh $(pwd)/dist/wamr-wasi-extensions + working-directory: wamr-wasi-extensions + + - name: Compress the binary + run: | + zip -r wamr-wasi-extensions-${{ inputs.ver_num }}.zip wamr-wasi-extensions + working-directory: wamr-wasi-extensions/dist + + - name: Upload release zip + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.upload_url }} + asset_path: wamr-wasi-extensions/dist/wamr-wasi-extensions-${{ inputs.ver_num }}.zip + asset_name: wamr-wasi-extensions-${{ inputs.ver_num }}.zip + asset_content_type: application/zip diff --git a/.github/workflows/release_process.yml b/.github/workflows/release_process.yml index 91f081fd21..bb99681dcb 100644 --- a/.github/workflows/release_process.yml +++ b/.github/workflows/release_process.yml @@ -239,3 +239,12 @@ jobs: arch: universal upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver}} + + release_wamr_wasi_extensions: + permissions: + contents: write # upload release artifact + needs: [create_tag, create_release] + uses: ./.github/workflows/build_wamr_wasi_extensions.yml + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + ver_num: ${{ needs.create_tag.outputs.new_ver }} From 68d5ae10d48567c0398d511e61866836db68b0ef Mon Sep 17 00:00:00 2001 From: Michiel Van Kenhove <16121929+Michielvk@users.noreply.github.com> Date: Wed, 2 Jul 2025 03:37:29 +0200 Subject: [PATCH 332/431] docs: fix cmake variable typo (#4441) --- product-mini/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product-mini/README.md b/product-mini/README.md index 5563d95793..65be5ce047 100644 --- a/product-mini/README.md +++ b/product-mini/README.md @@ -111,7 +111,7 @@ The Fast JIT is a lightweight JIT engine with quick startup, small footprint and (6) To enable the `Multi-tier JIT` mode: ``` Bash mkdir build && cd build -cmake .. -DWAMR_BUILD_FAST_JTI=1 -DWAMR_BUILD_JIT=1 +cmake .. -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 make ``` 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. From ee056d80766a422f0500be6571e402a38b8087f0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 3 Jul 2025 11:17:19 +0900 Subject: [PATCH 333/431] wasi_nn_llamacpp.c: validate input tensor type/dimensions (#4442) --- core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 ce72afa74d..7f30f2b4d7 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -411,6 +411,18 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index, char *prompt_text = (char *)wasi_nn_tensor->data.buf; uint32_t prompt_text_len = wasi_nn_tensor->data.size; + // note: buf[0] == 1 is a workaround for + // https://github.com/second-state/WasmEdge-WASINN-examples/issues/196. + // we may remove it in future. + if (wasi_nn_tensor->type != u8 || wasi_nn_tensor->dimensions->size != 1 + || !(wasi_nn_tensor->dimensions->buf[0] == 1 + || wasi_nn_tensor->dimensions->buf[0] == prompt_text_len)) { + return invalid_argument; + } + if (wasi_nn_tensor->dimensions->buf[0] == 1 && prompt_text_len != 1) { + NN_WARN_PRINTF("Ignoring seemingly wrong input tensor dimensions."); + } + #ifndef NDEBUG NN_DBG_PRINTF("--------------------------------------------------"); NN_DBG_PRINTF("prompt_text: %.*s", (int)prompt_text_len, prompt_text); From 8a55a1e7a1ff42cf91394587ced72917daa2e3fc Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Fri, 4 Jul 2025 10:44:51 +0800 Subject: [PATCH 334/431] Shared heap enhancements for Interpreter and AOT (#4400) Propose two enhancements: - Shared heap created from preallocated memory buffer: The user can create a shared heap from a pre-allocated buffer and see that memory region as one large chunk; there's no need to dynamically manage it(malloc/free). The user needs to make sure the native address and size of that memory region are valid. - Introduce shared heap chain: The user can create a shared heap chain, from the wasm app point of view, it's still a continuous memory region in wasm app's point of view while in the native it can consist of multiple shared heaps (each of which is a continuous memory region). For example, one 500MB shared heap 1 and one 500 MB shared heap 2 form a chain, in Wasm's point of view, it's one 1GB shared heap. After these enhancements, the data sharing between wasm apps, and between hosts can be more efficient and flexible. Admittedly shared heap management can be more complex for users, but it's similar to the zero-overhead principle. No overhead will be imposed for the users who don't use the shared heap enhancement or don't use the shared heap at all. --- core/iwasm/aot/aot_reloc.h | 8 + core/iwasm/aot/aot_runtime.c | 12 + core/iwasm/aot/aot_runtime.h | 5 +- core/iwasm/common/wasm_memory.c | 546 +++++++--- core/iwasm/common/wasm_memory.h | 52 +- core/iwasm/common/wasm_runtime_common.c | 34 + core/iwasm/common/wasm_runtime_common.h | 8 + core/iwasm/compilation/aot_emit_memory.c | 752 ++++++++++---- core/iwasm/compilation/aot_llvm.c | 174 +++- core/iwasm/compilation/aot_llvm.h | 5 + core/iwasm/include/aot_comp_option.h | 1 + core/iwasm/include/wasm_export.h | 39 +- core/iwasm/interpreter/wasm_interp_classic.c | 38 - core/iwasm/interpreter/wasm_interp_fast.c | 38 +- core/iwasm/interpreter/wasm_runtime.c | 1 + core/iwasm/interpreter/wasm_runtime.h | 20 +- samples/shared-heap/CMakeLists.txt | 30 +- samples/shared-heap/README.md | 50 + .../shared-heap/images/shared_heap_chain.png | Bin 0 -> 111396 bytes samples/shared-heap/src/main.c | 10 +- samples/shared-heap/src/shared_heap_chain.c | 321 ++++++ samples/shared-heap/wasm-apps/CMakeLists.txt | 4 +- samples/shared-heap/wasm-apps/test1.c | 11 + samples/shared-heap/wasm-apps/test2.c | 14 +- tests/unit/CMakeLists.txt | 28 +- tests/unit/shared-heap/CMakeLists.txt | 12 +- tests/unit/shared-heap/shared_heap_test.cc | 981 ++++++++++++++++-- .../unit/shared-heap/wasm-apps/CMakeLists.txt | 103 +- .../bulk-memory/test_bulk_memory.wasm | Bin 0 -> 63 bytes .../bulk-memory/test_bulk_memory.wat | 12 + .../wasm-apps/memory64/CMakeLists.txt | 68 ++ tests/unit/shared-heap/wasm-apps/test.c | 30 +- .../shared-heap/wasm-apps/test_addr_conv.c | 14 + wamr-compiler/CMakeLists.txt | 2 + wamr-compiler/main.c | 14 +- 35 files changed, 2786 insertions(+), 651 deletions(-) create mode 100644 samples/shared-heap/README.md create mode 100644 samples/shared-heap/images/shared_heap_chain.png create mode 100644 samples/shared-heap/src/shared_heap_chain.c create mode 100644 tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wasm create mode 100644 tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wat create mode 100644 tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt diff --git a/core/iwasm/aot/aot_reloc.h b/core/iwasm/aot/aot_reloc.h index ca9ba17f1f..ed225b5e0d 100644 --- a/core/iwasm/aot/aot_reloc.h +++ b/core/iwasm/aot/aot_reloc.h @@ -185,6 +185,13 @@ typedef struct { #define REG_STRINGREF_SYM() #endif +#if WASM_ENABLE_SHARED_HEAP != 0 +#define REG_SHARED_HEAP_SYM() \ + REG_SYM(wasm_runtime_check_and_update_last_used_shared_heap), +#else +#define REG_SHARED_HEAP_SYM() +#endif + #define REG_COMMON_SYMBOLS \ REG_SYM(aot_set_exception_with_id), \ REG_SYM(aot_invoke_native), \ @@ -218,6 +225,7 @@ typedef struct { REG_LLVM_PGO_SYM() \ REG_GC_SYM() \ REG_STRINGREF_SYM() \ + REG_SHARED_HEAP_SYM() \ #define CHECK_RELOC_OFFSET(data_size) do { \ if (!check_reloc_offset(target_section_size, \ diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 6c14036801..9f9c6ab436 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -60,6 +60,16 @@ bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0); bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj) == 8); bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_start_off) == 16); +bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_end_off) == 24); +bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap) == 32); + +bh_static_assert(offsetof(WASMSharedHeap, next) == 0); +bh_static_assert(offsetof(WASMSharedHeap, chain_next) == 8); +bh_static_assert(offsetof(WASMSharedHeap, heap_handle) == 16); +bh_static_assert(offsetof(WASMSharedHeap, base_addr) == 24); +bh_static_assert(offsetof(WASMSharedHeap, size) == 32); +bh_static_assert(offsetof(WASMSharedHeap, start_off_mem64) == 40); +bh_static_assert(offsetof(WASMSharedHeap, start_off_mem32) == 48); bh_static_assert(sizeof(CApiFuncImport) == sizeof(uintptr_t) * 3); @@ -1989,6 +1999,8 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, #else extra->shared_heap_start_off.u32[0] = UINT32_MAX; #endif + /* After shared heap chain, will early stop if shared heap is NULL */ + extra->shared_heap = NULL; #if WASM_ENABLE_PERF_PROFILING != 0 total_size = sizeof(AOTFuncPerfProfInfo) diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index e957f3959f..d06cd10812 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -125,6 +125,8 @@ typedef struct AOTModuleInstanceExtra { */ DefPointer(uint8 *, shared_heap_base_addr_adj); MemBound shared_heap_start_off; + MemBound shared_heap_end_off; + DefPointer(WASMSharedHeap *, shared_heap); WASMModuleInstanceExtraCommon common; @@ -142,9 +144,6 @@ typedef struct AOTModuleInstanceExtra { WASMModuleInstanceCommon **import_func_module_insts; #endif -#if WASM_ENABLE_SHARED_HEAP != 0 - WASMSharedHeap *shared_heap; -#endif } AOTModuleInstanceExtra; #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 1f942ec6c3..59d478c96f 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -143,7 +143,7 @@ is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst) #if WASM_ENABLE_SHARED_HEAP != 0 static void * -wasm_mmap_linear_memory(uint64_t map_size, uint64 commit_size); +wasm_mmap_linear_memory(uint64 map_size, uint64 commit_size); static void wasm_munmap_linear_memory(void *mapped_mem, uint64 commit_size, uint64 map_size); @@ -177,39 +177,54 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args) goto fail1; } - if (!(heap->heap_handle = - runtime_malloc(mem_allocator_get_heap_struct_size()))) { + size = align_uint(size, os_getpagesize()); + if (size > APP_HEAP_SIZE_MAX || size < APP_HEAP_SIZE_MIN) { + LOG_WARNING("Invalid size of shared heap"); goto fail2; } - size = align_uint(size, os_getpagesize()); heap->size = size; heap->start_off_mem64 = UINT64_MAX - heap->size + 1; heap->start_off_mem32 = UINT32_MAX - heap->size + 1; + heap->attached_count = 0; + + if (init_args->pre_allocated_addr != NULL) { + /* Create shared heap from a pre allocated buffer, its size need to + * align with system page */ + if (size != init_args->size) { + LOG_WARNING("Pre allocated size need to be aligned with system " + "page size to create shared heap"); + goto fail2; + } - if (size > APP_HEAP_SIZE_MAX || size < APP_HEAP_SIZE_MIN) { - LOG_WARNING("Invalid size of shared heap"); - goto fail3; + heap->heap_handle = NULL; + heap->base_addr = init_args->pre_allocated_addr; } + else { + if (!(heap->heap_handle = + runtime_malloc(mem_allocator_get_heap_struct_size()))) { + goto fail2; + } #ifndef OS_ENABLE_HW_BOUND_CHECK - map_size = size; + map_size = size; #else - /* Totally 8G is mapped, the opcode load/store address range is 0 to 8G: - * ea = i + memarg.offset - * both i and memarg.offset are u32 in range 0 to 4G - * so the range of ea is 0 to 8G - */ - map_size = 8 * (uint64)BH_GB; + /* Totally 8G is mapped, the opcode load/store address range is 0 to 8G: + * ea = i + memarg.offset + * both i and memarg.offset are u32 in range 0 to 4G + * so the range of ea is 0 to 8G + */ + map_size = 8 * (uint64)BH_GB; #endif - if (!(heap->base_addr = wasm_mmap_linear_memory(map_size, size))) { - goto fail3; - } - if (!mem_allocator_create_with_struct_and_pool( - heap->heap_handle, heap_struct_size, heap->base_addr, size)) { - LOG_WARNING("init share heap failed"); - goto fail4; + if (!(heap->base_addr = wasm_mmap_linear_memory(map_size, size))) { + goto fail3; + } + if (!mem_allocator_create_with_struct_and_pool( + heap->heap_handle, heap_struct_size, heap->base_addr, size)) { + LOG_WARNING("init share heap failed"); + goto fail4; + } } os_mutex_lock(&shared_heap_list_lock); @@ -233,6 +248,219 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args) return NULL; } +WASMSharedHeap * +wasm_runtime_chain_shared_heaps(WASMSharedHeap *head, WASMSharedHeap *body) +{ + WASMSharedHeap *cur; + bool heap_handle_exist = false; + + if (!head || !body) { + LOG_WARNING("Invalid shared heap to chain."); + return NULL; + } + heap_handle_exist = head->heap_handle != NULL; + + os_mutex_lock(&shared_heap_list_lock); + if (head->attached_count != 0 || body->attached_count != 0) { + LOG_WARNING("To create shared heap chain, all shared heap need to be " + "detached first."); + os_mutex_unlock(&shared_heap_list_lock); + return NULL; + } + for (cur = shared_heap_list; cur; cur = cur->next) { + if (cur->chain_next == body || cur->chain_next == head) { + LOG_WARNING( + "To create shared heap chain, both the 'head' and 'body' " + "shared heap can't already be the 'body' in another a chain"); + os_mutex_unlock(&shared_heap_list_lock); + return NULL; + } + if (cur == head && cur->chain_next) { + LOG_WARNING( + "To create shared heap chain, the 'head' shared heap can't " + "already be the 'head' in another a chain"); + os_mutex_unlock(&shared_heap_list_lock); + return NULL; + } + } + for (cur = body; cur; cur = cur->chain_next) { + if (cur->heap_handle && heap_handle_exist) { + LOG_WARNING( + "To create shared heap chain, only one of shared heap can " + "dynamically shared_heap_malloc and shared_heap_free, the rest " + "can only be pre-allocated shared heap"); + os_mutex_unlock(&shared_heap_list_lock); + return NULL; + } + if (cur->heap_handle) + heap_handle_exist = true; + } + + head->start_off_mem64 = body->start_off_mem64 - head->size; + head->start_off_mem32 = body->start_off_mem32 - head->size; + head->chain_next = body; + os_mutex_unlock(&shared_heap_list_lock); + return head; +} + +WASMSharedHeap * +wasm_runtime_unchain_shared_heaps(WASMSharedHeap *head, bool entire_chain) +{ + WASMSharedHeap *cur, *tmp; + + if (!head || !head->chain_next) { + LOG_WARNING("Invalid shared heap chain to disconnect the head from."); + return NULL; + } + + os_mutex_lock(&shared_heap_list_lock); + if (head->attached_count != 0) { + LOG_WARNING("To disconnect the shared heap head from the shared heap " + "chain, the shared heap chain needs to be detached first."); + os_mutex_unlock(&shared_heap_list_lock); + return NULL; + } + + cur = head; + while (cur && cur->chain_next) { + cur->start_off_mem64 = UINT64_MAX - cur->size + 1; + cur->start_off_mem32 = UINT32_MAX - cur->size + 1; + tmp = cur; + cur = cur->chain_next; + tmp->chain_next = NULL; + if (!entire_chain) + break; + } + os_mutex_unlock(&shared_heap_list_lock); + return cur; +} + +static uint8 * +get_last_used_shared_heap_base_addr_adj(WASMModuleInstanceCommon *module_inst) +{ +#if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode) { + WASMModuleInstanceExtra *e = + (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; + return e->shared_heap_base_addr_adj; + } +#endif /* end of WASM_ENABLE_INTERP != 0 */ +#if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT) { + AOTModuleInstanceExtra *e = + (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; + return e->shared_heap_base_addr_adj; + } +#endif /* end of WASM_ENABLE_AOT != 0 */ + return 0; +} + +static uintptr_t +get_last_used_shared_heap_start_offset(WASMModuleInstanceCommon *module_inst) +{ +#if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode) { + WASMModuleInstanceExtra *e = + (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + return e->shared_heap_start_off.u64; +#else + return e->shared_heap_start_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_INTERP != 0 */ +#if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT) { + AOTModuleInstanceExtra *e = + (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + return e->shared_heap_start_off.u64; +#else + return e->shared_heap_start_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_AOT != 0 */ + return 0; +} + +static uintptr_t +get_last_used_shared_heap_end_offset(WASMModuleInstanceCommon *module_inst) +{ +#if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode) { + WASMModuleInstanceExtra *e = + (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + return e->shared_heap_end_off.u64; +#else + return e->shared_heap_end_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_INTERP != 0 */ +#if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT) { + AOTModuleInstanceExtra *e = + (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + return e->shared_heap_end_off.u64; +#else + return e->shared_heap_end_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_AOT != 0 */ + return 0; +} + +static void +update_last_used_shared_heap(WASMModuleInstanceCommon *module_inst, + WASMSharedHeap *shared_heap, bool is_memory64) +{ +#if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode) { + WASMModuleInstanceExtra *e = + (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + if (is_memory64) + e->shared_heap_start_off.u64 = shared_heap->start_off_mem64; + else + e->shared_heap_start_off.u64 = shared_heap->start_off_mem32; + e->shared_heap_end_off.u64 = + e->shared_heap_start_off.u64 - 1 + shared_heap->size; + e->shared_heap_base_addr_adj = + shared_heap->base_addr - e->shared_heap_start_off.u64; +#else + e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32; + e->shared_heap_end_off.u32[0] = + e->shared_heap_start_off.u32[0] - 1 + shared_heap->size; + e->shared_heap_base_addr_adj = + shared_heap->base_addr - e->shared_heap_start_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_INTERP != 0 */ +#if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT) { + AOTModuleInstanceExtra *e = + (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; +#if UINTPTR_MAX == UINT64_MAX + if (is_memory64) + e->shared_heap_start_off.u64 = shared_heap->start_off_mem64; + else + e->shared_heap_start_off.u64 = shared_heap->start_off_mem32; + e->shared_heap_end_off.u64 = + e->shared_heap_start_off.u64 - 1 + shared_heap->size; + e->shared_heap_base_addr_adj = + shared_heap->base_addr - e->shared_heap_start_off.u64; +#else + e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32; + e->shared_heap_end_off.u32[0] = + e->shared_heap_start_off.u32[0] - 1 + shared_heap->size; + e->shared_heap_base_addr_adj = + shared_heap->base_addr - e->shared_heap_start_off.u32[0]; +#endif + } +#endif /* end of WASM_ENABLE_AOT != 0 */ +} + bool wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst, WASMSharedHeap *shared_heap) @@ -263,20 +491,6 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst, return false; } e->shared_heap = shared_heap; -#if WASM_ENABLE_JIT != 0 -#if UINTPTR_MAX == UINT64_MAX - if (memory->is_memory64) - e->shared_heap_start_off.u64 = shared_heap->start_off_mem64; - else - e->shared_heap_start_off.u64 = shared_heap->start_off_mem32; - e->shared_heap_base_addr_adj = - shared_heap->base_addr - e->shared_heap_start_off.u64; -#else - e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32; - e->shared_heap_base_addr_adj = - shared_heap->base_addr - e->shared_heap_start_off.u32[0]; -#endif -#endif /* end of WASM_ENABLE_JIT != 0 */ } #endif /* end of WASM_ENABLE_INTERP != 0 */ #if WASM_ENABLE_AOT != 0 @@ -288,21 +502,13 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst, return false; } e->shared_heap = shared_heap; -#if UINTPTR_MAX == UINT64_MAX - if (memory->is_memory64) - e->shared_heap_start_off.u64 = shared_heap->start_off_mem64; - else - e->shared_heap_start_off.u64 = shared_heap->start_off_mem32; - e->shared_heap_base_addr_adj = - shared_heap->base_addr - e->shared_heap_start_off.u64; -#else - e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32; - e->shared_heap_base_addr_adj = - shared_heap->base_addr - e->shared_heap_start_off.u32[0]; -#endif } #endif /* end of WASM_ENABLE_AOT != 0 */ + update_last_used_shared_heap(module_inst, shared_heap, memory->is_memory64); + os_mutex_lock(&shared_heap_list_lock); + shared_heap->attached_count++; + os_mutex_unlock(&shared_heap_list_lock); return true; } @@ -320,30 +526,46 @@ wasm_runtime_attach_shared_heap(WASMModuleInstanceCommon *module_inst, void wasm_runtime_detach_shared_heap_internal(WASMModuleInstanceCommon *module_inst) { + /* Reset shared_heap_end_off = UINT64/32_MAX - 1 to handling a corner case, + app_offset >= shared_heap_start && app_offset <= shared_heap_end-bytes+1 + when bytes=1 and both e->shared_heap_start_off and e->shared_heap_end_off + is 0xffffffff */ #if WASM_ENABLE_INTERP != 0 if (module_inst->module_type == Wasm_Module_Bytecode) { WASMModuleInstanceExtra *e = (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; + if (e->shared_heap != NULL) { + os_mutex_lock(&shared_heap_list_lock); + e->shared_heap->attached_count--; + os_mutex_unlock(&shared_heap_list_lock); + } e->shared_heap = NULL; -#if WASM_ENABLE_JIT != 0 #if UINTPTR_MAX == UINT64_MAX e->shared_heap_start_off.u64 = UINT64_MAX; + e->shared_heap_end_off.u64 = UINT64_MAX - 1; #else e->shared_heap_start_off.u32[0] = UINT32_MAX; + e->shared_heap_end_off.u32[0] = UINT32_MAX - 1; #endif e->shared_heap_base_addr_adj = NULL; -#endif } #endif /* end of WASM_ENABLE_INTERP != 0 */ #if WASM_ENABLE_AOT != 0 if (module_inst->module_type == Wasm_Module_AoT) { AOTModuleInstanceExtra *e = (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; + if (e->shared_heap != NULL) { + os_mutex_lock(&shared_heap_list_lock); + e->shared_heap->attached_count--; + os_mutex_unlock(&shared_heap_list_lock); + } e->shared_heap = NULL; #if UINTPTR_MAX == UINT64_MAX e->shared_heap_start_off.u64 = UINT64_MAX; + e->shared_heap_end_off.u64 = UINT64_MAX - 1; #else e->shared_heap_start_off.u32[0] = UINT32_MAX; + e->shared_heap_end_off.u32[0] = UINT32_MAX - 1; #endif e->shared_heap_base_addr_adj = NULL; } @@ -385,71 +607,93 @@ wasm_runtime_get_shared_heap(WASMModuleInstanceCommon *module_inst_comm) return get_shared_heap(module_inst_comm); } -static bool +bool is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, bool is_memory64, uint64 app_offset, uint32 bytes) { - WASMSharedHeap *heap = get_shared_heap(module_inst); + WASMSharedHeap *heap = get_shared_heap(module_inst), *cur; + uint64 shared_heap_start, shared_heap_end; if (!heap) { - return false; + goto fail; } if (bytes == 0) { bytes = 1; } - if (!is_memory64) { - if (app_offset >= heap->start_off_mem32 - && app_offset <= UINT32_MAX - bytes + 1) { - return true; - } + shared_heap_start = + (uint64)get_last_used_shared_heap_start_offset(module_inst); + shared_heap_end = (uint64)get_last_used_shared_heap_end_offset(module_inst); + if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start + && app_offset <= shared_heap_end - bytes + 1) { + return true; } - else { - if (app_offset >= heap->start_off_mem64 - && app_offset <= UINT64_MAX - bytes + 1) { + + /* Early stop for app start address not in the shared heap(chain) at all */ + shared_heap_start = + is_memory64 ? heap->start_off_mem64 : heap->start_off_mem32; + shared_heap_end = is_memory64 ? UINT64_MAX : UINT32_MAX; + if (bytes - 1 > shared_heap_end || app_offset < shared_heap_start + || app_offset > shared_heap_end - bytes + 1) { + goto fail; + } + + /* Find the exact shared heap that app addr is in, and update last used + * shared heap info in module inst extra */ + for (cur = heap; cur; cur = cur->chain_next) { + shared_heap_start = + is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32; + shared_heap_end = shared_heap_start - 1 + cur->size; + if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start + && app_offset <= shared_heap_end - bytes + 1) { + update_last_used_shared_heap(module_inst, cur, is_memory64); return true; } } +fail: return false; } static bool is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, - uint8 *addr, uint32 bytes) + bool is_memory64, uint8 *addr, uint32 bytes) { - WASMSharedHeap *heap = get_shared_heap(module_inst); - uintptr_t base_addr; - uintptr_t addr_int; - uintptr_t end_addr; + WASMSharedHeap *cur, *heap = get_shared_heap(module_inst); + uintptr_t base_addr, addr_int, end_addr; if (!heap) { - return false; + goto fail; } - base_addr = (uintptr_t)heap->base_addr; - addr_int = (uintptr_t)addr; - if (addr_int < base_addr) { - return false; - } + /* Iterate through shared heap chain to find whether native addr in one of + * shared heap */ + for (cur = heap; cur != NULL; cur = cur->chain_next) { + base_addr = (uintptr_t)cur->base_addr; + addr_int = (uintptr_t)addr; + if (addr_int < base_addr) + continue; - end_addr = addr_int + bytes; - /* Check for overflow */ - if (end_addr <= addr_int) { - return false; - } + end_addr = addr_int + bytes; + /* Check for overflow */ + if (end_addr <= addr_int) + continue; - if (end_addr > base_addr + heap->size) { - return false; + if (end_addr > base_addr + cur->size) + continue; + + update_last_used_shared_heap(module_inst, cur, is_memory64); + return true; } - return true; +fail: + return false; } uint64 wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, - uint64_t size, void **p_native_addr) + uint64 size, void **p_native_addr) { WASMMemoryInstance *memory = wasm_get_default_memory((WASMModuleInstance *)module_inst); @@ -459,6 +703,14 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, if (!memory || !shared_heap) return 0; + while (shared_heap && !shared_heap->heap_handle) { + shared_heap = shared_heap->chain_next; + } + if (!shared_heap) { + LOG_WARNING("Can't allocate from pre allocated shared heap"); + return 0; + } + native_addr = mem_allocator_malloc(shared_heap->heap_handle, size); if (!native_addr) return 0; @@ -467,12 +719,10 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, *p_native_addr = native_addr; } - if (memory->is_memory64) - return shared_heap->start_off_mem64 - + ((uint8 *)native_addr - shared_heap->base_addr); - else - return shared_heap->start_off_mem32 - + ((uint8 *)native_addr - shared_heap->base_addr); + return memory->is_memory64 + ? shared_heap->start_off_mem64 + : shared_heap->start_off_mem32 + + ((uint8 *)native_addr - shared_heap->base_addr); } void @@ -487,6 +737,14 @@ wasm_runtime_shared_heap_free(WASMModuleInstanceCommon *module_inst, uint64 ptr) return; } + while (shared_heap && !shared_heap->heap_handle) { + shared_heap = shared_heap->chain_next; + } + if (!shared_heap) { + LOG_WARNING("The address to free is from pre allocated shared heap"); + return; + } + if (memory->is_memory64) { if (ptr < shared_heap->start_off_mem64) { /* ptr can not > UINT64_MAX */ LOG_WARNING("The address to free isn't in shared heap"); @@ -564,14 +822,16 @@ destroy_shared_heaps() while (heap) { cur = heap; heap = heap->next; - mem_allocator_destroy(cur->heap_handle); - wasm_runtime_free(cur->heap_handle); + if (cur->heap_handle) { + mem_allocator_destroy(cur->heap_handle); + wasm_runtime_free(cur->heap_handle); #ifndef OS_ENABLE_HW_BOUND_CHECK - map_size = cur->size; + map_size = cur->size; #else - map_size = 8 * (uint64)BH_GB; + map_size = 8 * (uint64)BH_GB; #endif - wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size); + wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size); + } wasm_runtime_free(cur); } os_mutex_destroy(&shared_heap_list_lock); @@ -798,6 +1058,10 @@ wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst_comm, WASMMemoryInstance *memory_inst; uint64 app_end_offset, max_linear_memory_size = MAX_LINEAR_MEMORY_SIZE; char *str, *str_end; +#if WASM_ENABLE_SHARED_HEAP != 0 + uintptr_t shared_heap_end_off; + char *shared_heap_base_addr_adj; +#endif bh_assert(module_inst_comm->module_type == Wasm_Module_Bytecode || module_inst_comm->module_type == Wasm_Module_AoT); @@ -814,12 +1078,12 @@ wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst_comm, #if WASM_ENABLE_SHARED_HEAP != 0 if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64, app_str_offset, 1)) { - WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); - str = (char *)shared_heap->base_addr - + (memory_inst->is_memory64 - ? (app_str_offset - shared_heap->start_off_mem64) - : (app_str_offset - shared_heap->start_off_mem32)); - str_end = (char *)shared_heap->base_addr + shared_heap->size; + shared_heap_end_off = + get_last_used_shared_heap_end_offset(module_inst_comm); + shared_heap_base_addr_adj = + (char *)get_last_used_shared_heap_base_addr_adj(module_inst_comm); + str = shared_heap_base_addr_adj + app_str_offset; + str_end = shared_heap_base_addr_adj + shared_heap_end_off + 1; } else #endif @@ -884,7 +1148,8 @@ wasm_runtime_validate_native_addr(WASMModuleInstanceCommon *module_inst_comm, } #if WASM_ENABLE_SHARED_HEAP != 0 - if (is_native_addr_in_shared_heap(module_inst_comm, native_ptr, size)) { + if (is_native_addr_in_shared_heap( + module_inst_comm, memory_inst->is_memory64, native_ptr, size)) { return true; } #endif @@ -926,17 +1191,8 @@ wasm_runtime_addr_app_to_native(WASMModuleInstanceCommon *module_inst_comm, #if WASM_ENABLE_SHARED_HEAP != 0 if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64, app_offset, 1)) { - WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); - uint64 shared_heap_start = 0; - - if (memory_inst && !memory_inst->is_memory64) { - shared_heap_start = shared_heap->start_off_mem32; - } - else if (memory_inst && memory_inst->is_memory64) { - shared_heap_start = shared_heap->start_off_mem64; - } - - return shared_heap->base_addr + app_offset - shared_heap_start; + return get_last_used_shared_heap_base_addr_adj(module_inst_comm) + + app_offset; } #endif @@ -974,29 +1230,17 @@ wasm_runtime_addr_native_to_app(WASMModuleInstanceCommon *module_inst_comm, bounds_checks = is_bounds_checks_enabled(module_inst_comm); -#if WASM_ENABLE_SHARED_HEAP != 0 - /* If shared heap is enabled, bounds check is always needed */ - bounds_checks = true; -#endif - memory_inst = wasm_get_default_memory(module_inst); if (!memory_inst) { return 0; } #if WASM_ENABLE_SHARED_HEAP != 0 - if (is_native_addr_in_shared_heap(module_inst_comm, addr, 1)) { - WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); - uint64 shared_heap_start = 0; - - if (memory_inst && !memory_inst->is_memory64) { - shared_heap_start = shared_heap->start_off_mem32; - } - else if (memory_inst && memory_inst->is_memory64) { - shared_heap_start = shared_heap->start_off_mem64; - } - - return shared_heap_start + (addr - shared_heap->base_addr); + if (is_native_addr_in_shared_heap(module_inst_comm, + memory_inst->is_memory64, addr, 1)) { + return (uint64)(uintptr_t)(addr + - get_last_used_shared_heap_base_addr_adj( + module_inst_comm)); } #endif @@ -1098,8 +1342,8 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str, uint8 *native_addr; bool bounds_checks; #if WASM_ENABLE_SHARED_HEAP != 0 - WASMSharedHeap *shared_heap; - bool is_in_shared_heap = false; + uint8 *shared_heap_base_addr_adj = NULL; + uintptr_t shared_heap_end_off = 0; #endif bh_assert(app_buf_addr <= UINTPTR_MAX && app_buf_size <= UINTPTR_MAX); @@ -1113,36 +1357,17 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str, if (is_app_addr_in_shared_heap((WASMModuleInstanceCommon *)module_inst, memory_inst->is_memory64, app_buf_addr, app_buf_size)) { - shared_heap = get_shared_heap((WASMModuleInstanceCommon *)module_inst); - native_addr = shared_heap->base_addr - + (memory_inst->is_memory64 - ? (app_buf_addr - shared_heap->start_off_mem64) - : (app_buf_addr - shared_heap->start_off_mem32)); - is_in_shared_heap = true; - } - else -#endif - { - native_addr = memory_inst->memory_data + (uintptr_t)app_buf_addr; - } - - bounds_checks = - is_bounds_checks_enabled((WASMModuleInstanceCommon *)module_inst); - - if (!bounds_checks) { - if (app_buf_addr == 0) { - native_addr = NULL; - } - goto success; - } - -#if WASM_ENABLE_SHARED_HEAP != 0 - if (is_in_shared_heap) { const char *str, *str_end; + shared_heap_base_addr_adj = get_last_used_shared_heap_base_addr_adj( + (WASMModuleInstanceCommon *)module_inst); + shared_heap_end_off = get_last_used_shared_heap_end_offset( + (WASMModuleInstanceCommon *)module_inst); + native_addr = shared_heap_base_addr_adj + (uintptr_t)app_buf_addr; - /* The whole string must be in the linear memory */ + /* The whole string must be in the shared heap */ str = (const char *)native_addr; - str_end = (const char *)shared_heap->base_addr + shared_heap->size; + str_end = + (const char *)shared_heap_base_addr_adj + shared_heap_end_off + 1; while (str < str_end && *str != '\0') str++; if (str == str_end) { @@ -1154,6 +1379,17 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str, } #endif + native_addr = memory_inst->memory_data + (uintptr_t)app_buf_addr; + bounds_checks = + is_bounds_checks_enabled((WASMModuleInstanceCommon *)module_inst); + + if (!bounds_checks) { + if (app_buf_addr == 0) { + native_addr = NULL; + } + goto success; + } + /* No need to check the app_offset and buf_size if memory access boundary check with hardware trap is enabled */ #ifndef OS_ENABLE_HW_BOUND_CHECK diff --git a/core/iwasm/common/wasm_memory.h b/core/iwasm/common/wasm_memory.h index bceea0ee43..48bd2179fe 100644 --- a/core/iwasm/common/wasm_memory.h +++ b/core/iwasm/common/wasm_memory.h @@ -41,10 +41,60 @@ SET_LINEAR_MEMORY_SIZE(WASMMemoryInstance *memory, uint64 size) #define SET_LINEAR_MEMORY_SIZE(memory, size) memory->memory_data_size = size #endif +#if WASM_ENABLE_INTERP != 0 #if WASM_ENABLE_SHARED_HEAP != 0 + +#if WASM_ENABLE_MULTI_MEMORY != 0 +/* Only enable shared heap for the default memory */ +#define is_default_memory (memidx == 0) +#else +#define is_default_memory true +#endif + +#if UINTPTR_MAX == UINT64_MAX +#define get_shared_heap_end_off() module->e->shared_heap_end_off.u64 +#else +#define get_shared_heap_end_off() \ + (uint64)(module->e->shared_heap_end_off.u32[0]) +#endif + +#if WASM_ENABLE_MEMORY64 != 0 +#define shared_heap_is_memory64 is_memory64 +#else +#define shared_heap_is_memory64 false +#endif + +#define app_addr_in_shared_heap(app_addr, bytes) \ + (is_default_memory \ + && is_app_addr_in_shared_heap((WASMModuleInstanceCommon *)module, \ + shared_heap_is_memory64, (uint64)app_addr, \ + bytes)) +#define shared_heap_addr_app_to_native(app_addr, native_addr) \ + native_addr = module->e->shared_heap_base_addr_adj + app_addr +#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \ + if (app_addr_in_shared_heap(app_addr, bytes)) \ + shared_heap_addr_app_to_native(app_addr, native_addr); \ + else + +#else /* else of WASM_ENABLE_SHARED_HEAP != 0 */ +#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) +#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ +#endif /* end of WASM_ENABLE_INTERP != 0 */ + +#if WASM_ENABLE_SHARED_HEAP != 0 +bool +is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, + bool is_memory64, uint64 app_offset, uint32 bytes); + WASMSharedHeap * wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args); +WASMSharedHeap * +wasm_runtime_chain_shared_heaps(WASMSharedHeap *head, WASMSharedHeap *body); + +WASMSharedHeap * +wasm_runtime_unchain_shared_heaps(WASMSharedHeap *head, bool entire_chain); + bool wasm_runtime_attach_shared_heap(WASMModuleInstanceCommon *module_inst, WASMSharedHeap *shared_heap); @@ -68,7 +118,7 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, void wasm_runtime_shared_heap_free(WASMModuleInstanceCommon *module_inst, uint64 ptr); -#endif +#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ bool wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type, diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index e1d3542b96..07fd0e8597 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7883,3 +7883,37 @@ wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module) return true; } + +#if WASM_ENABLE_SHARED_HEAP != 0 +bool +wasm_runtime_check_and_update_last_used_shared_heap( + WASMModuleInstanceCommon *module_inst, uintptr_t app_offset, size_t bytes, + uintptr_t *shared_heap_start_off_p, uintptr_t *shared_heap_end_off_p, + uint8 **shared_heap_base_addr_adj_p, bool is_memory64) +{ + WASMSharedHeap *heap = wasm_runtime_get_shared_heap(module_inst), *cur; + uint64 shared_heap_start, shared_heap_end; + + if (bytes == 0) { + bytes = 1; + } + + /* Find the exact shared heap that app addr is in, and update last used + * shared heap info in func context */ + for (cur = heap; cur; cur = cur->chain_next) { + shared_heap_start = + is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32; + shared_heap_end = shared_heap_start - 1 + cur->size; + if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start + && app_offset <= shared_heap_end - bytes + 1) { + *shared_heap_start_off_p = (uintptr_t)shared_heap_start; + *shared_heap_end_off_p = (uintptr_t)shared_heap_end; + *shared_heap_base_addr_adj_p = + cur->base_addr - (uintptr_t)shared_heap_start; + return true; + } + } + + return false; +} +#endif diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index ad22ea10ba..a40756a451 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -1336,6 +1336,14 @@ void wasm_runtime_set_linux_perf(bool flag); #endif +#if WASM_ENABLE_SHARED_HEAP != 0 +bool +wasm_runtime_check_and_update_last_used_shared_heap( + WASMModuleInstanceCommon *module_inst, uintptr_t app_offset, size_t bytes, + uintptr_t *shared_heap_start_off_p, uintptr_t *shared_heap_end_off_p, + uint8 **shared_heap_base_addr_adj_p, bool is_memory64); +#endif + #ifdef __cplusplus } #endif diff --git a/core/iwasm/compilation/aot_emit_memory.c b/core/iwasm/compilation/aot_emit_memory.c index e685fccd92..0659c2b408 100644 --- a/core/iwasm/compilation/aot_emit_memory.c +++ b/core/iwasm/compilation/aot_emit_memory.c @@ -10,6 +10,40 @@ #include "aot_intrinsic.h" #include "aot_emit_control.h" +#define BUILD_IS_NOT_NULL(value, res, name) \ + do { \ + if (!(res = LLVMBuildIsNotNull(comp_ctx->builder, value, name))) { \ + aot_set_last_error("llvm build is not null failed."); \ + goto fail; \ + } \ + } while (0) + +#define BUILD_BR(llvm_block) \ + do { \ + if (!LLVMBuildBr(comp_ctx->builder, llvm_block)) { \ + aot_set_last_error("llvm build br failed."); \ + goto fail; \ + } \ + } while (0) + +#define BUILD_COND_BR(value_if, block_then, block_else) \ + do { \ + if (!LLVMBuildCondBr(comp_ctx->builder, value_if, block_then, \ + block_else)) { \ + aot_set_last_error("llvm build cond br failed."); \ + goto fail; \ + } \ + } while (0) + +#define BUILD_TRUNC(value, data_type) \ + do { \ + if (!(value = LLVMBuildTrunc(comp_ctx->builder, value, data_type, \ + "val_trunc"))) { \ + aot_set_last_error("llvm build trunc failed."); \ + goto fail; \ + } \ + } while (0) + #define BUILD_ICMP(op, left, right, res, name) \ do { \ if (!(res = \ @@ -111,6 +145,418 @@ ffs(int n) static LLVMValueRef get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); +#if WASM_ENABLE_SHARED_HEAP != 0 +uint32 +get_module_inst_extra_offset(AOTCompContext *comp_ctx); + +#define BUILD_LOAD_PTR(ptr, data_type, res) \ + do { \ + if (!(res = LLVMBuildLoad2(comp_ctx->builder, data_type, ptr, \ + "load_value"))) { \ + aot_set_last_error("llvm build load failed"); \ + goto fail; \ + } \ + } while (0) + +/* Update last used shared heap info(alloc ptr) in function ctx: + * 1. shared_heap_start_off 2. shared_heap_end_off 3. shared_heap_base_addr_adj + */ +bool +aot_check_shared_heap_chain_and_update(AOTCompContext *comp_ctx, + AOTFuncContext *func_ctx, + LLVMBasicBlockRef check_succ, + LLVMValueRef start_offset, + LLVMValueRef bytes, bool is_memory64) +{ + LLVMValueRef param_values[7], ret_value, func, value, cmp; + LLVMTypeRef param_types[7], ret_type, func_type, func_ptr_type; + + param_types[0] = INT8_PTR_TYPE; + param_types[1] = INTPTR_T_TYPE; + param_types[2] = SIZE_T_TYPE; + param_types[3] = INTPTR_T_PTR_TYPE; + param_types[4] = INTPTR_T_PTR_TYPE; + param_types[5] = INT8_PTR_TYPE; + param_types[6] = INT8_TYPE; + ret_type = INT8_TYPE; + + GET_AOT_FUNCTION(wasm_runtime_check_and_update_last_used_shared_heap, 7); + + /* Call function */ + param_values[0] = func_ctx->aot_inst; + param_values[1] = start_offset; + param_values[2] = bytes; + /* pass alloc ptr */ + param_values[3] = func_ctx->shared_heap_start_off; + param_values[4] = func_ctx->shared_heap_end_off; + param_values[5] = func_ctx->shared_heap_base_addr_adj; + param_values[6] = is_memory64 ? I8_ONE : I8_ZERO; + + if (!(ret_value = LLVMBuildCall2(comp_ctx->builder, func_type, func, + param_values, 7, "call"))) { + aot_set_last_error("llvm build call failed."); + goto fail; + } + + BUILD_ICMP(LLVMIntEQ, ret_value, I8_ZERO, cmp, "shared_heap_oob"); + if (!aot_emit_exception(comp_ctx, func_ctx, + EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp, + check_succ)) { + goto fail; + } + + return true; +fail: + return false; +} + +/* + * Setup the basic blocks for shared heap and shared chain memory checks. + * + * Arguments: + * block_curr: The current basic block. + * app_addr_in_cache_shared_heap: Output, block for cache shared heap. + * app_addr_in_linear_mem: Output, block for linear memory. + * app_addr_in_shared_heap_chain: Output, block for shared heap chain + * (only for shared heap chain). + * check_shared_heap_chain: Output, block for checking shared heap chain + * (only for shared heap chain). + * + * Topology: + * If enable_shared_heap: + * block_curr -> app_addr_in_cache_shared_heap + * -> app_addr_in_linear_mem + * If enable_shared_chain: + * block_curr -> app_addr_in_shared_heap_chain + * -> app_addr_in_cache_shared_heap + * -> check_shared_heap_chain + * -> app_addr_in_linear_mem + */ +static bool +setup_shared_heap_blocks(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMBasicBlockRef block_curr, + LLVMBasicBlockRef *app_addr_in_cache_shared_heap, + LLVMBasicBlockRef *app_addr_in_linear_mem, + LLVMBasicBlockRef *app_addr_in_shared_heap_chain, + LLVMBasicBlockRef *check_shared_heap_chain) +{ + ADD_BASIC_BLOCK(*app_addr_in_cache_shared_heap, + "app_addr_in_cache_shared_heap"); + ADD_BASIC_BLOCK(*app_addr_in_linear_mem, "app_addr_in_linear_mem"); + + if (comp_ctx->enable_shared_heap) { + LLVMMoveBasicBlockAfter(*app_addr_in_cache_shared_heap, block_curr); + LLVMMoveBasicBlockAfter(*app_addr_in_linear_mem, + *app_addr_in_cache_shared_heap); + } + else if (comp_ctx->enable_shared_chain) { + ADD_BASIC_BLOCK(*app_addr_in_shared_heap_chain, + "app_addr_in_shared_heap_chain"); + ADD_BASIC_BLOCK(*check_shared_heap_chain, "check_shared_heap_chain"); + LLVMMoveBasicBlockAfter(*app_addr_in_shared_heap_chain, block_curr); + LLVMMoveBasicBlockAfter(*app_addr_in_cache_shared_heap, + *app_addr_in_shared_heap_chain); + LLVMMoveBasicBlockAfter(*check_shared_heap_chain, + *app_addr_in_cache_shared_heap); + LLVMMoveBasicBlockAfter(*app_addr_in_linear_mem, + *app_addr_in_cache_shared_heap); + } + + return true; +fail: + return false; +} + +/* + * Build a branch to check if start_offset is in the shared heap chain region. + * + * Arguments: + * start_offset: The offset to check. + * app_addr_in_shared_heap_chain: Block to branch if in shared heap chain. + * app_addr_in_linear_mem: Block to branch if not in shared heap chain. + */ +static bool +build_check_app_addr_in_shared_heap_chain( + AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMValueRef start_offset, LLVMBasicBlockRef app_addr_in_shared_heap_chain, + LLVMBasicBlockRef app_addr_in_linear_mem) +{ + LLVMValueRef is_in_shared_heap = NULL; + + /* Use start_offset > func_ctx->shared_heap_head_start_off to test + * start_off falls in shared heap chain memory region. The shared heap + * chain oob will be detected in app_addr_in_shared_heap block or + * aot_check_shared_heap_chain_and_update function + */ + BUILD_ICMP(LLVMIntUGT, start_offset, func_ctx->shared_heap_head_start_off, + is_in_shared_heap, "shared_heap_lb_cmp"); + BUILD_COND_BR(is_in_shared_heap, app_addr_in_shared_heap_chain, + app_addr_in_linear_mem); + + SET_BUILD_POS(app_addr_in_shared_heap_chain); + + return true; +fail: + return false; +} + +/* + * Build the conditional branch for cache shared heap or shared heap chain. + * + * Arguments: + * cmp: The condition for being in cache shared heap. + * app_addr_in_cache_shared_heap: Block for cache shared heap. + * app_addr_in_linear_mem: Block for linear memory. + * check_shared_heap_chain: Block for checking shared heap chain. + * bytes: The access size in bytes. + * start_offset: The offset to check. + * is_memory64: Whether memory is 64-bit. + */ +static bool +build_shared_heap_conditional_branching( + AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMValueRef cmp, + LLVMBasicBlockRef app_addr_in_cache_shared_heap, + LLVMBasicBlockRef app_addr_in_linear_mem, + LLVMBasicBlockRef check_shared_heap_chain, LLVMValueRef bytes, + LLVMValueRef start_offset, bool is_memory64) +{ + if (comp_ctx->enable_shared_heap) { + BUILD_COND_BR(cmp, app_addr_in_cache_shared_heap, + app_addr_in_linear_mem); + } + else if (comp_ctx->enable_shared_chain) { + BUILD_COND_BR(cmp, app_addr_in_cache_shared_heap, + check_shared_heap_chain); + SET_BUILD_POS(check_shared_heap_chain); + if (!aot_check_shared_heap_chain_and_update( + comp_ctx, func_ctx, app_addr_in_cache_shared_heap, start_offset, + bytes, is_memory64)) + goto fail; + } + return true; +fail: + return false; +} + +/* + * Get the native address in the cache shared heap. + * + * Arguments: + * start_offset: The offset to use for address calculation. + * maddr: Output, the native address that in the cache shared heap. + */ +static bool +build_get_maddr_in_cache_shared_heap(AOTCompContext *comp_ctx, + AOTFuncContext *func_ctx, + LLVMValueRef start_offset, + LLVMValueRef *maddr) +{ + LLVMValueRef shared_heap_base_addr_adj; + /* load the local variable */ + BUILD_LOAD_PTR(func_ctx->shared_heap_base_addr_adj, INT8_PTR_TYPE, + shared_heap_base_addr_adj); + if (!(*maddr = LLVMBuildInBoundsGEP2( + comp_ctx->builder, INT8_TYPE, shared_heap_base_addr_adj, + &start_offset, 1, "maddr_cache_shared_heap"))) { + aot_set_last_error("llvm build inbounds gep failed"); + goto fail; + } + + return true; +fail: + return false; +} + +/* + * Check for memory overflow in shared heap for normal memory access. + * + * Arguments: + * block_curr: The current basic block. + * block_maddr_phi: The phi block for memory address. + * maddr_phi: The phi node for memory address. + * start_offset: The first offset to check. + * mem_base_addr: The base address of memory. Only used with segue. + * bytes_u32: The access size in bytes. + * is_memory64: Whether memory is wasm64 memory. + * is_target_64bit: Whether target is 64-bit. + * enable_segue: Whether to use segment register addressing. + */ +static bool +aot_check_shared_heap_memory_overflow( + AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMBasicBlockRef block_curr, LLVMBasicBlockRef block_maddr_phi, + LLVMValueRef maddr_phi, LLVMValueRef start_offset, + LLVMValueRef mem_base_addr, uint32 bytes_u32, bool is_memory64, + bool is_target_64bit, bool enable_segue) +{ + LLVMBasicBlockRef app_addr_in_cache_shared_heap, app_addr_in_linear_mem; + LLVMBasicBlockRef app_addr_in_shared_heap_chain = NULL, + check_shared_heap_chain = NULL; + LLVMValueRef cmp, cmp1, cmp2, shared_heap_start_off, shared_heap_end_off, + shared_heap_check_bound, maddr = NULL; + /* On 64/32-bit target, the offset is 64/32-bit */ + LLVMTypeRef offset_type = is_target_64bit ? I64_TYPE : I32_TYPE; + LLVMValueRef length, bytes; + + if (!setup_shared_heap_blocks( + comp_ctx, func_ctx, block_curr, &app_addr_in_cache_shared_heap, + &app_addr_in_linear_mem, &app_addr_in_shared_heap_chain, + &check_shared_heap_chain)) + goto fail; + LLVMMoveBasicBlockAfter(block_maddr_phi, app_addr_in_linear_mem); + + /* Early branching when it's not in shared heap chain at all */ + if (comp_ctx->enable_shared_chain + && !build_check_app_addr_in_shared_heap_chain( + comp_ctx, func_ctx, start_offset, app_addr_in_shared_heap_chain, + app_addr_in_linear_mem)) + goto fail; + + /* Load the local variable of the function */ + BUILD_LOAD_PTR(func_ctx->shared_heap_start_off, offset_type, + shared_heap_start_off); + BUILD_LOAD_PTR(func_ctx->shared_heap_end_off, offset_type, + shared_heap_end_off); + /* Check if the app address is in the cache shared heap range. + * If yes, branch to the cache branch; if not, check the shared heap chain + */ + BUILD_ICMP(LLVMIntUGE, start_offset, shared_heap_start_off, cmp, + "cmp_cache_shared_heap_start"); + length = + is_target_64bit ? I64_CONST(bytes_u32 - 1) : I32_CONST(bytes_u32 - 1); + CHECK_LLVM_CONST(length); + BUILD_OP(Sub, shared_heap_end_off, length, shared_heap_check_bound, + "cache_shared_heap_end_bound"); + BUILD_ICMP(LLVMIntULE, start_offset, shared_heap_check_bound, cmp1, + "cmp_cache_shared_heap_end"); + BUILD_OP(And, cmp, cmp1, cmp2, "is_in_cache_shared_heap"); + /* Conditional branching based on whether in cached shared heap */ + bytes = is_target_64bit ? I64_CONST(bytes_u32) : I32_CONST(bytes_u32); + if (!build_shared_heap_conditional_branching( + comp_ctx, func_ctx, cmp2, app_addr_in_cache_shared_heap, + app_addr_in_linear_mem, check_shared_heap_chain, bytes, + start_offset, is_memory64)) + goto fail; + + SET_BUILD_POS(app_addr_in_cache_shared_heap); + if (!build_get_maddr_in_cache_shared_heap(comp_ctx, func_ctx, start_offset, + &maddr)) + goto fail; + + if (enable_segue) { + LLVMValueRef mem_base_addr_u64, maddr_u64, offset_to_mem_base; + if (!(maddr_u64 = LLVMBuildPtrToInt(comp_ctx->builder, maddr, I64_TYPE, + "maddr_u64")) + || !(mem_base_addr_u64 = + LLVMBuildPtrToInt(comp_ctx->builder, mem_base_addr, + I64_TYPE, "mem_base_addr_u64"))) { + aot_set_last_error("llvm build ptr to int failed"); + goto fail; + } + if (!(offset_to_mem_base = + LLVMBuildSub(comp_ctx->builder, maddr_u64, mem_base_addr_u64, + "offset_to_mem_base"))) { + aot_set_last_error("llvm build sub failed"); + goto fail; + } + if (!(maddr = LLVMBuildIntToPtr(comp_ctx->builder, offset_to_mem_base, + INT8_PTR_TYPE_GS, + "maddr_shared_heap_segue"))) { + aot_set_last_error("llvm build int to ptr failed."); + goto fail; + } + } + + LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_cache_shared_heap, 1); + BUILD_BR(block_maddr_phi); + SET_BUILD_POS(app_addr_in_linear_mem); + + return true; +fail: + return false; +} + +/* + * Check for memory overflow in shared heap for bulk memory access. + * + * Arguments: + * block_curr: The current basic block. + * block_maddr_phi: The phi block for memory address. + * check_succ: The block to branch to on success. + * maddr_phi: The phi node for memory address. + * start_offset: The offset to check. + * max_addr: The maximum address to check. + * bytes: The access size in bytes (LLVMValueRef). + * is_memory64: Whether memory is wasm64 memory. + * is_target_64bit: Whether target is 64-bit. + */ +static bool +aot_check_bulk_memory_shared_heap_memory_overflow( + AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMBasicBlockRef block_curr, LLVMBasicBlockRef block_maddr_phi, + LLVMBasicBlockRef check_succ, LLVMValueRef maddr_phi, + LLVMValueRef start_offset, LLVMValueRef max_addr, LLVMValueRef bytes, + bool is_memory64, bool is_target_64bit) +{ + LLVMBasicBlockRef app_addr_in_cache_shared_heap, app_addr_in_linear_mem; + LLVMBasicBlockRef app_addr_in_shared_heap_chain = NULL, + check_shared_heap_chain = NULL; + LLVMValueRef cmp, cmp1, cmp2, shared_heap_start_off, shared_heap_end_off, + maddr = NULL, max_offset; + /* On 64/32-bit target, the offset is 64/32-bit */ + LLVMTypeRef offset_type = is_target_64bit ? I64_TYPE : I32_TYPE; + + if (!setup_shared_heap_blocks( + comp_ctx, func_ctx, block_curr, &app_addr_in_cache_shared_heap, + &app_addr_in_linear_mem, &app_addr_in_shared_heap_chain, + &check_shared_heap_chain)) + goto fail; + LLVMMoveBasicBlockAfter(block_maddr_phi, check_succ); + + /* Early branching when it's not in shared heap chain at all */ + if (comp_ctx->enable_shared_chain + && !build_check_app_addr_in_shared_heap_chain( + comp_ctx, func_ctx, start_offset, app_addr_in_shared_heap_chain, + app_addr_in_linear_mem)) + goto fail; + + /* Load the local variable of the function */ + BUILD_LOAD_PTR(func_ctx->shared_heap_start_off, offset_type, + shared_heap_start_off); + BUILD_LOAD_PTR(func_ctx->shared_heap_end_off, offset_type, + shared_heap_end_off); + /* Check if the app address is in the cache shared heap range. + * If yes, branch to the cache branch; if not, check the shared heap chain + */ + BUILD_ICMP(LLVMIntUGE, start_offset, shared_heap_start_off, cmp, + "cmp_cache_shared_heap_start"); + BUILD_OP(Add, max_addr, is_target_64bit ? I64_NEG_ONE : I32_NEG_ONE, + max_offset, "max_offset"); + BUILD_ICMP(LLVMIntULE, max_offset, shared_heap_end_off, cmp1, + "cmp_cache_shared_heap_end"); + BUILD_OP(And, cmp, cmp1, cmp2, "is_in_cache_shared_heap"); + /* Conditional branching based on whether in cached shared heap */ + if (!build_shared_heap_conditional_branching( + comp_ctx, func_ctx, cmp2, app_addr_in_cache_shared_heap, + app_addr_in_linear_mem, check_shared_heap_chain, bytes, + start_offset, is_memory64)) + goto fail; + + SET_BUILD_POS(app_addr_in_cache_shared_heap); + if (!build_get_maddr_in_cache_shared_heap(comp_ctx, func_ctx, start_offset, + &maddr)) + goto fail; + + LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_cache_shared_heap, 1); + BUILD_BR(block_maddr_phi); + SET_BUILD_POS(app_addr_in_linear_mem); + + return true; +fail: + return false; +} +#endif + LLVMValueRef aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, mem_offset_t offset, uint32 bytes, bool enable_segue, @@ -118,10 +564,10 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, { LLVMValueRef offset_const = MEMORY64_COND_VALUE(I64_CONST(offset), I32_CONST(offset)); - LLVMValueRef addr, maddr, maddr_phi = NULL, offset1, cmp1, cmp2, cmp; + LLVMValueRef addr, maddr, offset1, cmp1, cmp; LLVMValueRef mem_base_addr, mem_check_bound; LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder); - LLVMBasicBlockRef check_succ, block_maddr_phi = NULL; + LLVMBasicBlockRef check_succ; AOTValue *aot_value_top; uint32 local_idx_of_aot_value = 0; uint64 const_value; @@ -136,6 +582,10 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, #else bool is_memory64 = IS_MEMORY64; #endif +#if WASM_ENABLE_SHARED_HEAP != 0 + LLVMValueRef maddr_phi = NULL; + LLVMBasicBlockRef block_maddr_phi = NULL; +#endif is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false; @@ -262,6 +712,13 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, *alignp = 1; } + /* The overflow check needs to be done under following conditions: + * 1. In 64-bit target, offset and addr will be extended to 64-bit + * 1.1 offset + addr can overflow when it's memory64 + * 1.2 no overflow when it's memory32 + * 2. In 32-bit target, offset and addr will be 32-bit + * 2.1 offset + addr can overflow when it's memory32 + */ if (is_target_64bit) { if (!(offset_const = LLVMBuildZExt(comp_ctx->builder, offset_const, I64_TYPE, "offset_i64")) @@ -275,7 +732,9 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, /* offset1 = offset + addr; */ BUILD_OP(Add, offset_const, addr, offset1, "offset1"); - if (is_memory64 && comp_ctx->enable_bound_check) { + /* 1.1 offset + addr can overflow when it's memory64 + * 2.1 Or when it's on 32-bit platform */ + if (is_memory64 || !is_target_64bit) { /* Check whether integer overflow occurs in offset + addr */ LLVMBasicBlockRef check_integer_overflow_end; ADD_BASIC_BLOCK(check_integer_overflow_end, @@ -289,23 +748,14 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } SET_BUILD_POS(check_integer_overflow_end); + block_curr = check_integer_overflow_end; } - if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { - LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; - LLVMValueRef is_in_shared_heap, shared_heap_check_bound = NULL; - - /* Add basic blocks */ - ADD_BASIC_BLOCK(app_addr_in_shared_heap, "app_addr_in_shared_heap"); - ADD_BASIC_BLOCK(app_addr_in_linear_mem, "app_addr_in_linear_mem"); +#if WASM_ENABLE_SHARED_HEAP != 0 + if (comp_ctx->enable_shared_heap + || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) { ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi"); - - LLVMMoveBasicBlockAfter(app_addr_in_shared_heap, block_curr); - LLVMMoveBasicBlockAfter(app_addr_in_linear_mem, - app_addr_in_shared_heap); - LLVMMoveBasicBlockAfter(block_maddr_phi, app_addr_in_linear_mem); - - LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi); + SET_BUILD_POS(block_maddr_phi); if (!(maddr_phi = LLVMBuildPhi(comp_ctx->builder, enable_segue ? INT8_PTR_TYPE_GS : INT8_PTR_TYPE, @@ -313,110 +763,16 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_set_last_error("llvm build phi failed"); goto fail; } + SET_BUILD_POS(block_curr); - LLVMPositionBuilderAtEnd(comp_ctx->builder, block_curr); - - if (!is_target_64bit) { - /* Check whether integer overflow occurs in addr + offset */ - LLVMBasicBlockRef check_integer_overflow_end; - ADD_BASIC_BLOCK(check_integer_overflow_end, - "check_integer_overflow_end"); - LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr); - - BUILD_ICMP(LLVMIntULT, offset1, addr, cmp1, "cmp1"); - if (!aot_emit_exception(comp_ctx, func_ctx, - EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, - cmp1, check_integer_overflow_end)) { - goto fail; - } - SET_BUILD_POS(check_integer_overflow_end); - } - - shared_heap_check_bound = - is_memory64 ? I64_CONST(UINT64_MAX - bytes + 1) - : (comp_ctx->pointer_size == sizeof(uint64) - ? I64_CONST(UINT32_MAX - bytes + 1) - : I32_CONST(UINT32_MAX - bytes + 1)); - CHECK_LLVM_CONST(shared_heap_check_bound); - - /* Check whether the bytes to access are in shared heap */ - if (!comp_ctx->enable_bound_check) { - /* Use IntUGT but not IntUGE to compare, since (1) in the ems - 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 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"); - /* We don't check the shared heap's upper boundary if boundary - check isn't enabled, the runtime may also use the guard pages - of shared heap to check the boundary if hardware boundary - check feature is enabled. */ - } - else { - /* Use IntUGT but not IntUGE to compare, same as above */ - BUILD_ICMP(LLVMIntUGT, offset1, func_ctx->shared_heap_start_off, - cmp1, "cmp1"); - /* Check the shared heap's upper boundary if boundary check is - enabled */ - BUILD_ICMP(LLVMIntULE, offset1, shared_heap_check_bound, cmp2, - "cmp2"); - BUILD_OP(And, cmp1, cmp2, is_in_shared_heap, "is_in_shared_heap"); - } - - if (!LLVMBuildCondBr(comp_ctx->builder, is_in_shared_heap, - app_addr_in_shared_heap, app_addr_in_linear_mem)) { - aot_set_last_error("llvm build cond br failed"); - goto fail; - } - - LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_shared_heap); - - /* Get native address inside shared heap */ - if (!(maddr = - LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, - func_ctx->shared_heap_base_addr_adj, - &offset1, 1, "maddr_shared_heap"))) { - aot_set_last_error("llvm build inbounds gep failed"); - goto fail; - } - - if (enable_segue) { - LLVMValueRef mem_base_addr_u64, maddr_u64, offset_to_mem_base; - - if (!(maddr_u64 = LLVMBuildPtrToInt(comp_ctx->builder, maddr, - I64_TYPE, "maddr_u64")) - || !(mem_base_addr_u64 = - LLVMBuildPtrToInt(comp_ctx->builder, mem_base_addr, - I64_TYPE, "mem_base_addr_u64"))) { - aot_set_last_error("llvm build ptr to int failed"); - goto fail; - } - if (!(offset_to_mem_base = - LLVMBuildSub(comp_ctx->builder, maddr_u64, - mem_base_addr_u64, "offset_to_mem_base"))) { - aot_set_last_error("llvm build sub failed"); - goto fail; - } - if (!(maddr = LLVMBuildIntToPtr( - comp_ctx->builder, offset_to_mem_base, INT8_PTR_TYPE_GS, - "maddr_shared_heap_segue"))) { - aot_set_last_error("llvm build int to ptr failed."); - goto fail; - } - } - - LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_shared_heap, 1); - - if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { - aot_set_last_error("llvm build br failed"); + if (!aot_check_shared_heap_memory_overflow( + comp_ctx, func_ctx, block_curr, block_maddr_phi, maddr_phi, + offset1, mem_base_addr, bytes, is_memory64, is_target_64bit, + enable_segue)) { goto fail; } - - LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_linear_mem); - block_curr = LLVMGetInsertBlock(comp_ctx->builder); } +#endif if (comp_ctx->enable_bound_check && !(is_local_of_aot_value @@ -449,21 +805,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } - if (is_target_64bit) { - BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp"); - } - else { - if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { - /* Check integer overflow has been checked above */ - BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp"); - } - else { - /* Check integer overflow */ - BUILD_ICMP(LLVMIntULT, offset1, addr, cmp1, "cmp1"); - BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp2, "cmp2"); - BUILD_OP(Or, cmp1, cmp2, cmp, "cmp"); - } - } + BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp"); /* Add basic blocks */ ADD_BASIC_BLOCK(check_succ, "check_succ"); @@ -509,17 +851,20 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, } } - if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { +#if WASM_ENABLE_SHARED_HEAP != 0 + if (comp_ctx->enable_shared_heap + || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) { block_curr = LLVMGetInsertBlock(comp_ctx->builder); LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1); if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { aot_set_last_error("llvm build br failed"); goto fail; } - LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi); + SET_BUILD_POS(block_maddr_phi); return maddr_phi; } else +#endif return maddr; fail: return NULL; @@ -544,15 +889,6 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMSetAlignment(value, known_align); \ } while (0) -#define BUILD_TRUNC(value, data_type) \ - do { \ - if (!(value = LLVMBuildTrunc(comp_ctx->builder, value, data_type, \ - "val_trunc"))) { \ - aot_set_last_error("llvm build trunc failed."); \ - goto fail; \ - } \ - } while (0) - #define BUILD_STORE() \ do { \ LLVMValueRef res; \ @@ -1150,16 +1486,23 @@ LLVMValueRef check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMValueRef offset, LLVMValueRef bytes) { - LLVMValueRef maddr, max_addr, cmp; - LLVMValueRef mem_base_addr, maddr_phi = NULL; + LLVMValueRef maddr, max_addr, cmp, cmp1; + LLVMValueRef mem_base_addr; LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder); - LLVMBasicBlockRef check_succ, block_maddr_phi = NULL; + LLVMBasicBlockRef check_succ; LLVMValueRef mem_size; + bool is_target_64bit; #if WASM_ENABLE_MEMORY64 == 0 bool is_memory64 = false; #else bool is_memory64 = IS_MEMORY64; #endif +#if WASM_ENABLE_SHARED_HEAP != 0 + LLVMValueRef maddr_phi = NULL; + LLVMBasicBlockRef block_maddr_phi = NULL; +#endif + + is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false; /* Get memory base address and memory data size */ #if WASM_ENABLE_SHARED_MEMORY != 0 @@ -1221,111 +1564,71 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, ADD_BASIC_BLOCK(check_succ, "check_succ"); LLVMMoveBasicBlockAfter(check_succ, block_curr); - offset = - LLVMBuildZExt(comp_ctx->builder, offset, I64_TYPE, "extend_offset"); - bytes = LLVMBuildZExt(comp_ctx->builder, bytes, I64_TYPE, "extend_len"); - if (!offset || !bytes) { - aot_set_last_error("llvm build zext failed."); - goto fail; + /* Same logic with aot_check_memory_overflow, offset and bytes are 32/64 + * bits on 32/64 bits platform */ + if (is_target_64bit) { + offset = + LLVMBuildZExt(comp_ctx->builder, offset, I64_TYPE, "extend_offset"); + bytes = LLVMBuildZExt(comp_ctx->builder, bytes, I64_TYPE, "extend_len"); + if (!offset || !bytes) { + aot_set_last_error("llvm build zext failed."); + goto fail; + } } BUILD_OP(Add, offset, bytes, max_addr, "max_addr"); - if (is_memory64 && comp_ctx->enable_bound_check) { - /* Check whether integer overflow occurs in offset + addr */ + /* Check overflow when it's memory64 or it's on 32 bits platform */ + if (is_memory64 || !is_target_64bit) { + /* Check whether integer overflow occurs in offset + bytes */ LLVMBasicBlockRef check_integer_overflow_end; ADD_BASIC_BLOCK(check_integer_overflow_end, "check_integer_overflow_end"); LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr); + /* offset + bytes can overflow yet is valid(for example, 0xffffffff, 1), + * allow it to be 0(either 0, 0 or overflow and valid) */ BUILD_ICMP(LLVMIntULT, max_addr, offset, cmp, "cmp"); + BUILD_ICMP(LLVMIntNE, max_addr, is_target_64bit ? I64_ZERO : I32_ZERO, + cmp1, "cmp1"); + BUILD_OP(And, cmp, cmp1, cmp, "overflow"); if (!aot_emit_exception(comp_ctx, func_ctx, EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp, check_integer_overflow_end)) { goto fail; } SET_BUILD_POS(check_integer_overflow_end); + block_curr = check_integer_overflow_end; } - if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { - LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; - LLVMValueRef shared_heap_start_off, shared_heap_check_bound; - LLVMValueRef max_offset, cmp1, cmp2, is_in_shared_heap; - - /* Add basic blocks */ - ADD_BASIC_BLOCK(app_addr_in_shared_heap, "app_addr_in_shared_heap"); - ADD_BASIC_BLOCK(app_addr_in_linear_mem, "app_addr_in_linear_mem"); +#if WASM_ENABLE_SHARED_HEAP != 0 + if (comp_ctx->enable_shared_heap + || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) { ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi"); - - LLVMMoveBasicBlockAfter(app_addr_in_shared_heap, block_curr); - LLVMMoveBasicBlockAfter(app_addr_in_linear_mem, - app_addr_in_shared_heap); - LLVMMoveBasicBlockAfter(block_maddr_phi, check_succ); - - LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi); + SET_BUILD_POS(block_maddr_phi); if (!(maddr_phi = LLVMBuildPhi(comp_ctx->builder, INT8_PTR_TYPE, "maddr_phi"))) { aot_set_last_error("llvm build phi failed"); goto fail; } + SET_BUILD_POS(block_curr); - LLVMPositionBuilderAtEnd(comp_ctx->builder, block_curr); - - shared_heap_start_off = func_ctx->shared_heap_start_off; - if (comp_ctx->pointer_size == sizeof(uint32)) { - if (!(shared_heap_start_off = - LLVMBuildZExt(comp_ctx->builder, shared_heap_start_off, - I64_TYPE, "shared_heap_start_off_u64"))) { - aot_set_last_error("llvm build zext failed"); - goto fail; - } - } - shared_heap_check_bound = - is_memory64 ? I64_CONST(UINT64_MAX) : I64_CONST(UINT32_MAX); - CHECK_LLVM_CONST(shared_heap_check_bound); - - /* Check whether the bytes to access are in shared heap */ - if (!comp_ctx->enable_bound_check) { - /* Use IntUGT but not IntUGE to compare, same as the check - in aot_check_memory_overflow */ - BUILD_ICMP(LLVMIntUGT, offset, func_ctx->shared_heap_start_off, - is_in_shared_heap, "is_in_shared_heap"); - } - else { - BUILD_ICMP(LLVMIntUGT, offset, func_ctx->shared_heap_start_off, - cmp1, "cmp1"); - BUILD_OP(Add, max_addr, I64_NEG_ONE, max_offset, "max_offset"); - BUILD_ICMP(LLVMIntULE, max_offset, shared_heap_check_bound, cmp2, - "cmp2"); - BUILD_OP(And, cmp1, cmp2, is_in_shared_heap, "is_in_shared_heap"); - } - - if (!LLVMBuildCondBr(comp_ctx->builder, is_in_shared_heap, - app_addr_in_shared_heap, app_addr_in_linear_mem)) { - aot_set_last_error("llvm build cond br failed"); - goto fail; - } - - LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_shared_heap); - - /* Get native address inside shared heap */ - if (!(maddr = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, - func_ctx->shared_heap_base_addr_adj, - &offset, 1, "maddr_shared_heap"))) { - aot_set_last_error("llvm build inbounds gep failed"); - goto fail; - } - LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_shared_heap, 1); - - if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { - aot_set_last_error("llvm build br failed"); + if (!aot_check_bulk_memory_shared_heap_memory_overflow( + comp_ctx, func_ctx, block_curr, block_maddr_phi, check_succ, + maddr_phi, offset, max_addr, bytes, is_memory64, + is_target_64bit)) { goto fail; } - - LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_linear_mem); - block_curr = LLVMGetInsertBlock(comp_ctx->builder); } +#endif + /* mem_size is always 64-bit, extend max_addr on 32 bits platform */ + if (!is_target_64bit + && !(max_addr = LLVMBuildZExt(comp_ctx->builder, max_addr, I64_TYPE, + "extend_max_addr"))) { + aot_set_last_error("llvm build zext failed."); + goto fail; + } BUILD_ICMP(LLVMIntUGT, max_addr, mem_size, cmp, "cmp_max_mem_addr"); if (!aot_emit_exception(comp_ctx, func_ctx, @@ -1341,7 +1644,9 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } - if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { +#if WASM_ENABLE_SHARED_HEAP != 0 + if (comp_ctx->enable_shared_heap + || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) { block_curr = LLVMGetInsertBlock(comp_ctx->builder); LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1); if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { @@ -1352,6 +1657,7 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, return maddr_phi; } else +#endif return maddr; fail: return NULL; diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 28b0da0a6c..a71e147a28 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -1517,73 +1517,154 @@ create_memory_info(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, return true; } +#define BUILD_IS_NOT_NULL(value, res, name) \ + do { \ + if (!(res = LLVMBuildIsNotNull(comp_ctx->builder, value, name))) { \ + aot_set_last_error("llvm build is not null failed."); \ + goto fail; \ + } \ + } while (0) + +#define get_module_extra_field_offset(field) \ + do { \ + offset_u32 = get_module_inst_extra_offset(comp_ctx); \ + if (comp_ctx->is_jit_mode) \ + offset_u32 += offsetof(WASMModuleInstanceExtra, field); \ + else \ + offset_u32 += offsetof(AOTModuleInstanceExtra, field); \ + } while (0) + +#define LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(field, type) \ + do { \ + get_module_extra_field_offset(field); \ + offset = I32_CONST(offset_u32); \ + CHECK_LLVM_CONST(offset); \ + if (!(field_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, \ + func_ctx->aot_inst, &offset, 1, \ + #field "_p"))) { \ + aot_set_last_error("llvm build inbounds gep failed"); \ + goto fail; \ + } \ + if (!(load_val = \ + LLVMBuildLoad2(comp_ctx->builder, type, field_p, #field))) { \ + aot_set_last_error("llvm build load failed"); \ + goto fail; \ + } \ + if (!(func_ctx->field = \ + LLVMBuildAlloca(comp_ctx->builder, type, #field))) { \ + aot_set_last_error("llvm build alloca failed"); \ + goto fail; \ + } \ + if (!LLVMBuildStore(comp_ctx->builder, load_val, func_ctx->field)) { \ + aot_set_last_error("llvm build store failed"); \ + goto fail; \ + } \ + } while (0) + static bool create_shared_heap_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) { - LLVMValueRef offset, base_addr_p, start_off_p, cmp; +#if WASM_ENABLE_SHARED_HEAP != 0 + LLVMValueRef offset, field_p, load_val, shared_heap_head_p, + shared_heap_head, cmp, field_p_or_default, shared_heap_head_start_off, + shared_heap_head_start_off_minus_one; + LLVMTypeRef shared_heap_offset_type; uint32 offset_u32; - - /* Load aot_inst->e->shared_heap_base_addr_adj */ - offset_u32 = get_module_inst_extra_offset(comp_ctx); -#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SHARED_HEAP != 0 - if (comp_ctx->is_jit_mode) - offset_u32 += - offsetof(WASMModuleInstanceExtra, shared_heap_base_addr_adj); - else +#if WASM_ENABLE_MEMORY64 == 0 + bool is_memory64 = false; +#else + bool is_memory64 = IS_MEMORY64; #endif - offset_u32 += - offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj); + + shared_heap_offset_type = + comp_ctx->pointer_size == sizeof(uint64) ? I64_TYPE : I32_TYPE; + + /* shared_heap_base_addr_adj, shared_heap_start_off, and + * shared_heap_end_off can be updated later, use local variable to + * represent them */ + LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_base_addr_adj, + INT8_PTR_TYPE); + LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_start_off, + shared_heap_offset_type); + LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_end_off, + shared_heap_offset_type); + + /* Shared Heap head start off won't be updated, no need to alloca */ + get_module_extra_field_offset(shared_heap); offset = I32_CONST(offset_u32); CHECK_LLVM_CONST(offset); - - if (!(base_addr_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, - func_ctx->aot_inst, &offset, 1, - "shared_heap_base_addr_adj_p"))) { + if (!(shared_heap_head_p = LLVMBuildInBoundsGEP2( + comp_ctx->builder, INT8_TYPE, func_ctx->aot_inst, &offset, 1, + "shared_heap_head_p"))) { aot_set_last_error("llvm build inbounds gep failed"); - return false; + goto fail; } - if (!(func_ctx->shared_heap_base_addr_adj = - LLVMBuildLoad2(comp_ctx->builder, INT8_PTR_TYPE, base_addr_p, - "shared_heap_base_addr_adj"))) { + if (!(shared_heap_head = + LLVMBuildLoad2(comp_ctx->builder, INT8_PTR_TYPE, + shared_heap_head_p, "shared_heap_head"))) { aot_set_last_error("llvm build load failed"); - return false; + goto fail; } + BUILD_IS_NOT_NULL(shared_heap_head, cmp, "has_shared_heap"); - /* Load aot_inst->e->shared_heap_start_off */ - offset_u32 = get_module_inst_extra_offset(comp_ctx); -#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SHARED_HEAP != 0 - if (comp_ctx->is_jit_mode) - offset_u32 += offsetof(WASMModuleInstanceExtra, shared_heap_start_off); - else -#endif - offset_u32 += offsetof(AOTModuleInstanceExtra, shared_heap_start_off); + if (is_memory64) { + offset_u32 = offsetof(WASMSharedHeap, start_off_mem64); + } + else { + offset_u32 = offsetof(WASMSharedHeap, start_off_mem32); + } offset = I32_CONST(offset_u32); CHECK_LLVM_CONST(offset); - - if (!(start_off_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, - func_ctx->aot_inst, &offset, 1, - "shared_heap_start_off_p"))) { + if (!(field_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, + shared_heap_head, &offset, 1, + "head_start_off_p"))) { aot_set_last_error("llvm build inbounds gep failed"); - return false; + goto fail; } - if (!(func_ctx->shared_heap_start_off = LLVMBuildLoad2( - comp_ctx->builder, - comp_ctx->pointer_size == sizeof(uint64) ? I64_TYPE : I32_TYPE, - start_off_p, "shared_heap_start_off"))) { - aot_set_last_error("llvm build load failed"); - return false; + + /* Select a valid shared heap head ptr or safe alloca ptr stores + * shared_heap_start_off(UINT32_MAX/UINT64_MAX) */ + if (!(field_p_or_default = LLVMBuildSelect(comp_ctx->builder, cmp, field_p, + func_ctx->shared_heap_start_off, + "ptr_or_default"))) { + aot_set_last_error("llvm build select failed"); + goto fail; } - if (!(cmp = LLVMBuildIsNotNull(comp_ctx->builder, - func_ctx->shared_heap_base_addr_adj, - "has_shared_heap"))) { - aot_set_last_error("llvm build is not null failed"); - return false; + if (!(shared_heap_head_start_off = LLVMBuildLoad2( + comp_ctx->builder, shared_heap_offset_type, field_p_or_default, + "shared_heap_head_start_off"))) { + aot_set_last_error("llvm build load failed"); + goto fail; + } + if (!(shared_heap_head_start_off_minus_one = LLVMBuildAdd( + comp_ctx->builder, shared_heap_head_start_off, + comp_ctx->pointer_size == sizeof(uint64) ? I64_NEG_ONE + : I32_NEG_ONE, + "head_start_off_minus_one"))) { + aot_set_last_error("llvm build load failed"); + goto fail; } + /* if there is attached shared heap(s), the value will be valid start_off-1, + * otherwise it will be UINT32_MAX/UINT64_MAX, so during the bounds checks, + * when has attached shared heap: + * offset > start_off - 1 => offset >= start_off + * when no attached shared heap: + * offset > UINT32_MAX/UINT64_MAX is always false + * */ + if (!(func_ctx->shared_heap_head_start_off = LLVMBuildSelect( + comp_ctx->builder, cmp, shared_heap_head_start_off_minus_one, + shared_heap_head_start_off, "head_start_off"))) { + aot_set_last_error("llvm build select failed"); + goto fail; + } return true; fail: return false; +#else /* else of WASM_ENABLE_SHARED_HEAP != 0 */ + return true; +#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ } static bool @@ -1877,7 +1958,7 @@ aot_create_func_context(const AOTCompData *comp_data, AOTCompContext *comp_ctx, } /* Load shared heap, shared heap start off mem32 or mem64 */ - if (comp_ctx->enable_shared_heap + if ((comp_ctx->enable_shared_heap || comp_ctx->enable_shared_chain) && !create_shared_heap_info(comp_ctx, func_ctx)) { goto fail; } @@ -2703,6 +2784,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) if (option->enable_shared_heap) comp_ctx->enable_shared_heap = true; + if (option->enable_shared_chain) + comp_ctx->enable_shared_chain = true; + comp_ctx->opt_level = option->opt_level; comp_ctx->size_level = option->size_level; diff --git a/core/iwasm/compilation/aot_llvm.h b/core/iwasm/compilation/aot_llvm.h index 6b1233c39f..b4228c67a0 100644 --- a/core/iwasm/compilation/aot_llvm.h +++ b/core/iwasm/compilation/aot_llvm.h @@ -254,8 +254,12 @@ typedef struct AOTFuncContext { bool mem_space_unchanged; AOTCheckedAddrList checked_addr_list; + /* The last accessed shared heap info */ LLVMValueRef shared_heap_base_addr_adj; LLVMValueRef shared_heap_start_off; + LLVMValueRef shared_heap_end_off; + /* The start offset of the head of shared heap chain */ + LLVMValueRef shared_heap_head_start_off; LLVMBasicBlockRef got_exception_block; LLVMBasicBlockRef func_return_block; @@ -486,6 +490,7 @@ typedef struct AOTCompContext { bool enable_gc; bool enable_shared_heap; + bool enable_shared_chain; uint32 opt_level; uint32 size_level; diff --git a/core/iwasm/include/aot_comp_option.h b/core/iwasm/include/aot_comp_option.h index 8391766232..e12f3f6fc3 100644 --- a/core/iwasm/include/aot_comp_option.h +++ b/core/iwasm/include/aot_comp_option.h @@ -79,6 +79,7 @@ typedef struct AOTCompOption { bool enable_stack_estimation; bool quick_invoke_c_api_import; bool enable_shared_heap; + bool enable_shared_chain; char *use_prof_file; uint32_t opt_level; uint32_t size_level; diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index ca96f5824d..59f93dc78d 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -349,6 +349,7 @@ typedef enum { typedef struct SharedHeapInitArgs { uint32_t size; + void *pre_allocated_addr; } SharedHeapInitArgs; /** @@ -2314,7 +2315,37 @@ WASM_RUNTIME_API_EXTERN wasm_shared_heap_t wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args); /** - * Attach a shared heap to a module instance + * This function links two shared heap(lists), `head` and `body` in to a single + * shared heap list, where `head` becomes the new shared heap list head. The + * shared heap list remains one continuous shared heap in wasm app's point of + * view. At most one shared heap in shared heap list can be dynamically + * allocated, the rest have to be the pre-allocated shared heap. * + * + * @param head The head of the shared heap chain. + * @param body The body of the shared heap chain to be appended. + * @return The new head of the shared heap chain. NULL if failed. + */ +WASM_RUNTIME_API_EXTERN wasm_shared_heap_t +wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head, + wasm_shared_heap_t body); + +/** + * This function unchains the shared heaps from the given head. If + * `entire_chain` is true, it will unchain the entire chain of shared heaps. + * Otherwise, it will unchain only the first shared heap in the chain. + * + * @param head The head of the shared heap chain. + * @param entire_chain A boolean flag indicating whether to unchain the entire + * chain. + * @return The new head of the shared heap chain. Or the last shared heap in the + * chain if `entire_chain` is true. + */ +wasm_shared_heap_t +wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head, bool entire_chain); + +/** + * Attach a shared heap, it can be the head of shared heap chain, in that case, + * attach the shared heap chain, to a module instance * * @param module_inst the module instance * @param shared_heap the shared heap @@ -2333,7 +2364,8 @@ WASM_RUNTIME_API_EXTERN void wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst); /** - * Allocate memory from a shared heap + * Allocate memory from a shared heap, or the non-preallocated shared heap from + * the shared heap chain * * @param module_inst the module instance * @param size required memory size @@ -2350,7 +2382,8 @@ wasm_runtime_shared_heap_malloc(wasm_module_inst_t module_inst, uint64_t size, void **p_native_addr); /** - * Free the memory allocated from shared heap + * Free the memory allocated from shared heap, or the non-preallocated shared + * heap from the shared heap chain * * @param module_inst the module instance * @param ptr the offset in wasm app diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 07cf6c1ffd..dbbc7af012 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -46,28 +46,6 @@ typedef float64 CellType_F64; #define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory) #endif -#if WASM_ENABLE_SHARED_HEAP != 0 -#if WASM_ENABLE_MULTI_MEMORY != 0 -/* Only enable shared heap for the default memory */ -#define is_default_memory (memidx == 0) -#else -#define is_default_memory true -#endif -#define app_addr_in_shared_heap(app_addr, bytes) \ - (shared_heap && is_default_memory && (app_addr) >= shared_heap_start_off \ - && (app_addr) <= shared_heap_end_off - bytes + 1) - -#define shared_heap_addr_app_to_native(app_addr, native_addr) \ - native_addr = shared_heap_base_addr + ((app_addr)-shared_heap_start_off) - -#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \ - if (app_addr_in_shared_heap(app_addr, bytes)) \ - shared_heap_addr_app_to_native(app_addr, native_addr); \ - else -#else -#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) -#endif - #if WASM_ENABLE_MEMORY64 == 0 #if (!defined(OS_ENABLE_HW_BOUND_CHECK) \ @@ -1670,22 +1648,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, if (memory) is_memory64 = memory->is_memory64; #endif -#if WASM_ENABLE_SHARED_HEAP != 0 - WASMSharedHeap *shared_heap = module->e->shared_heap; - uint8 *shared_heap_base_addr = shared_heap ? shared_heap->base_addr : NULL; -#if WASM_ENABLE_MEMORY64 != 0 - uint64 shared_heap_start_off = - shared_heap ? (is_memory64 ? shared_heap->start_off_mem64 - : shared_heap->start_off_mem32) - : 0; - uint64 shared_heap_end_off = - shared_heap ? (is_memory64 ? UINT64_MAX : UINT32_MAX) : 0; -#else - uint64 shared_heap_start_off = - shared_heap ? shared_heap->start_off_mem32 : 0; - uint64 shared_heap_end_off = shared_heap ? UINT32_MAX : 0; -#endif -#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ #if WASM_ENABLE_MULTI_MEMORY != 0 uint32 memidx = 0; uint32 memidx_cached = (uint32)-1; diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 4e5edf41b6..4c7b246d5d 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -41,22 +41,6 @@ typedef float64 CellType_F64; #define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory) #endif -#if WASM_ENABLE_SHARED_HEAP != 0 -#define app_addr_in_shared_heap(app_addr, bytes) \ - (shared_heap && (app_addr) >= shared_heap_start_off \ - && (app_addr) <= shared_heap_end_off - bytes + 1) - -#define shared_heap_addr_app_to_native(app_addr, native_addr) \ - native_addr = shared_heap_base_addr + ((app_addr)-shared_heap_start_off) - -#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \ - if (app_addr_in_shared_heap(app_addr, bytes)) \ - shared_heap_addr_app_to_native(app_addr, native_addr); \ - else -#else -#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) -#endif - #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 #define CHECK_MEMORY_OVERFLOW(bytes) \ @@ -1590,21 +1574,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, bool is_return_call = false; #endif #if WASM_ENABLE_SHARED_HEAP != 0 - WASMSharedHeap *shared_heap = module->e ? module->e->shared_heap : NULL; - uint8 *shared_heap_base_addr = shared_heap ? shared_heap->base_addr : NULL; - /* -#if WASM_ENABLE_MEMORY64 != 0 - uint64 shared_heap_start_off = - shared_heap ? (is_memory64 ? shared_heap->start_off_mem64 - : shared_heap->start_off_mem32) - : 0; - uint64 shared_heap_end_off = - shared_heap ? (is_memory64 ? UINT64_MAX : UINT32_MAX) : 0; -#else - */ /* TODO: uncomment the code when memory64 is enabled for fast-interp */ - uint64 shared_heap_start_off = - shared_heap ? shared_heap->start_off_mem32 : 0; - uint64 shared_heap_end_off = shared_heap ? UINT32_MAX : 0; + /* TODO: currently flowing two variables are only dummy for shared heap + * boundary check, need to be updated when multi-memory or memory64 + * proposals are to be implemented */ + bool is_memory64 = false; + uint32 memidx = 0; + (void)is_memory64; + (void)memidx; /* #endif */ #endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 42178c594d..8e38a0778b 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -2818,6 +2818,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, #else module_inst->e->shared_heap_start_off.u32[0] = UINT32_MAX; #endif + module_inst->e->shared_heap = NULL; #endif #if WASM_ENABLE_GC != 0 diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 3d91d8b601..16c670f0fa 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -93,12 +93,21 @@ typedef union { } MemBound; typedef struct WASMSharedHeap { - struct WASMSharedHeap *next; - void *heap_handle; - uint8 *base_addr; + /* The global shared heap list maintained in runtime, used for runtime + * destroy */ + DefPointer(struct WASMSharedHeap *, next); + /* The logical shared heap chain the shared heap in */ + DefPointer(struct WASMSharedHeap *, chain_next); + /* Will be null if shared heap is created from pre allocated memory chunk + * and don't need to dynamic malloc and free */ + DefPointer(void *, heap_handle); + DefPointer(uint8 *, base_addr); uint64 size; uint64 start_off_mem64; uint64 start_off_mem32; + /* The number of wasm apps it attached to, for a shared heap chain, only the + * list head need to maintain the valid attached_count */ + uint8 attached_count; } WASMSharedHeap; struct WASMMemoryInstance { @@ -364,8 +373,6 @@ typedef struct WASMModuleInstanceExtra { #endif #if WASM_ENABLE_SHARED_HEAP != 0 - WASMSharedHeap *shared_heap; -#if WASM_ENABLE_JIT != 0 /* * Adjusted shared heap based addr to simple the calculation * in the aot code. The value is: @@ -373,7 +380,8 @@ typedef struct WASMModuleInstanceExtra { */ uint8 *shared_heap_base_addr_adj; MemBound shared_heap_start_off; -#endif + MemBound shared_heap_end_off; + WASMSharedHeap *shared_heap; #endif #if WASM_ENABLE_DEBUG_INTERP != 0 \ diff --git a/samples/shared-heap/CMakeLists.txt b/samples/shared-heap/CMakeLists.txt index 6346d077e7..03906f7c32 100644 --- a/samples/shared-heap/CMakeLists.txt +++ b/samples/shared-heap/CMakeLists.txt @@ -83,17 +83,21 @@ target_link_libraries(vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthre include_directories(${CMAKE_CURRENT_LIST_DIR}/src) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) +add_executable (shared_heap_chain_test src/shared_heap_chain.c ${UNCOMMON_SHARED_SOURCE}) add_executable (shared_heap_test src/main.c ${UNCOMMON_SHARED_SOURCE}) check_pie_supported() set_target_properties (shared_heap_test PROPERTIES POSITION_INDEPENDENT_CODE ON) if (APPLE) - target_link_libraries (shared_heap_test vmlib -lm -ldl -lpthread) + set (LIBS vmlib -lm -ldl -lpthread) else () - target_link_libraries (shared_heap_test vmlib -lm -ldl -lpthread -lrt) + set (LIBS vmlib -lm -ldl -lpthread -lrt) endif () +target_link_libraries (shared_heap_chain_test ${LIBS}) +target_link_libraries (shared_heap_test ${LIBS}) + add_subdirectory(wasm-apps) if (WAMR_BUILD_AOT EQUAL 1) @@ -107,21 +111,31 @@ if (WAMR_BUILD_AOT EQUAL 1) ) if (WAMR_COMPILER) message (CHECK_PASS "found") - else() + else () message (CHECK_FAIL "not found") - endif() + endif () if (NOT EXISTS ${WAMR_COMPILER}) message (FATAL_ERROR "Please build wamrc under ${WAMR_ROOT_DIR}/wamr-compiler") - else() + else () message (STATUS "WAMR_COMPILER is ${WAMR_COMPILER}") - endif() + endif () + + if (WAMR_BUILD_TARGET STREQUAL "X86_32") + set (WAMR_COMPILER_FLAGS --enable-shared-heap --target=i386) + set (WAMR_COMPILER_CHAIN_FLAGS --enable-shared-chain --target=i386) + else () + set (WAMR_COMPILER_FLAGS --enable-shared-heap) + set (WAMR_COMPILER_CHAIN_FLAGS --enable-shared-chain) + endif () add_custom_target( wasm_to_aot ALL DEPENDS wasm-apps/test1.wasm wasm-apps/test2.wasm ${WAMR_COMPILER} - COMMAND ${WAMR_COMPILER} --enable-shared-heap -o wasm-apps/test1.aot wasm-apps/test1.wasm - COMMAND ${WAMR_COMPILER} --enable-shared-heap -o wasm-apps/test2.aot wasm-apps/test2.wasm + COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_FLAGS} -o wasm-apps/test1.aot wasm-apps/test1.wasm + COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_FLAGS} -o wasm-apps/test2.aot wasm-apps/test2.wasm + COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_CHAIN_FLAGS} -o wasm-apps/test1_chain.aot wasm-apps/test1.wasm + COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_CHAIN_FLAGS} -o wasm-apps/test2_chain.aot wasm-apps/test2.wasm WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif() diff --git a/samples/shared-heap/README.md b/samples/shared-heap/README.md new file mode 100644 index 0000000000..6e43ceab91 --- /dev/null +++ b/samples/shared-heap/README.md @@ -0,0 +1,50 @@ +# Shared heap Sample introduction + +This is a sample to show how to use the shared heap feature in WAMR. The shared heap feature allows multiple WASM instances to share the same memory space. This feature is useful when you want to run multiple WASM instances in the same process and share data between them. The sandbox nature of WASM is still maintained in the shared heap by WAMR. But the data management and correct data synchronization in shared heap is relied on the user's implementation. + +> Note: The shared heap feature is experimental feature, it should be used with caution. It's optional and only available when building WAMR with the CMake cache variable `WAMR_BUILD_SHARED_HEAP` set to 1. + +## Build and run the sample + +To build the shared heap used in multi thread sample and the shared heap chain sample with following commands: + +```bash +cmake -S . -B build +cmake --build build +``` + +For the shared heap sample, it demonstrates how to create a shared heap and use it shares data between two WASM instances, which would satisfy most of the use cases. Use the following commands to run the sample: + +```bash +cd build +./shared_heap_test +``` + +For the shared heap chain sample. It chains a pre-allocated heap and a normal shared heap to one chain(linked list) as a whole and attaches/detaches all together, and pass the WASM address directly between two WASM instances. Use the following commands to run the sample: + +```bash +cd build +./shared_heap_chain_test +``` + +## How to use shared heap + +The shared heap is an advanced feature in WAMR that gives the user flexibility to share data between multiple WASM instances(it will be the same address mapping for different WASM instance) or between WebAssembly and the host without incurring any copy overhead. The shared heap can be regarded as an extension of the WebAssembly linear memory. But it also heavily relies on the user's implementation to manage the shared data correctly. The following are some takeaway points to help the user use the shared heap correctly. + +### Create and manage shared heap + +You can create a shared heap by calling the `wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)` API. And based on the `init_args`, you can create a shared heap in two ways: + +1. WAMR managed shared heap: when only `init_args.size` is given and `init_args.pre_allocated_addr` stays as NULL, WAMR will allocate a shared heap(not from the linear memory) with the given size. The shared heap will be managed by WAMR, the wasm app or host(WAMR users) can dynamically manage memory from it by calling `wasm_runtime_shared_heap_malloc()` and `wasm_runtime_shared_heap_free()` on demand. Only the memory allocated from the shared heap is valid and can be shared, not the unallocated part of shared heap memory. And it will be automatically freed when runtime is destroyed(when `wasm_runtime_destroy()` is called). + +2. Preallocated shared heap: the user can also use a pre-allocated memory(it can be allocated from the system heap, or is a static global buffer, the correctness of its accessibility and size needs to be ensured by the user) as a shared heap by giving `init_args.pre_allocated_addr` and `init_args.size`. This kind of shared heap serves as an area for data exchange, primarily between the host and WebAssembly. Any data within this area can be directly accessed by both sides (assuming the layout of the data structure is known). For instance, the host can store large structured variables in this space, allowing the WebAssembly application to operate on them without the need for copying. And the pre-allocated memory will relies on user to manage its life cycle. + +After creation, the shared heap can be attached to a WASM instance(an additional segment appended to the end of the linear memory) by calling `wasm_runtime_attach_shared_heap(wasm_module_inst_t module_inst, wasm_shared_heap_t shared_heap)`. And it can be detached by calling `wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst)`. So that the data sharing can only happen between the WASM instances that have the same shared heap attached, complete by user's choice. + +#### Shared heap chain + +Sometimes you may want to use multiple shared heaps to attach together as a chain(linked list) and to share data more flexibly. You can call `wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head, wasm_shared_heap_t body)` to chain two shared heaps together. The shared heap list remains one continuous shared heap in wasm app's point of view. To create a shared heap chain, the shared heaps can't be currently attached to any WASM instance. + +> PS: At most one shared heap in shared heap list can be WAMR managed shared heap, the rest have to be the pre-allocated shared heap. + +![shared-heap-chain](./images/shared_heap_chain.png) diff --git a/samples/shared-heap/images/shared_heap_chain.png b/samples/shared-heap/images/shared_heap_chain.png new file mode 100644 index 0000000000000000000000000000000000000000..740a709d49b3bbb2a8d8423221e18e10953e789a GIT binary patch literal 111396 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

`Lcru75oB+swyxO=|RJiyw^u9Pd2)V6Agog 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

s(FcNuP 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 H2EP9fC-k>^ literal 0 HcmV?d00001 diff --git a/samples/shared-heap/src/main.c b/samples/shared-heap/src/main.c index f4024f08c2..111da33999 100644 --- a/samples/shared-heap/src/main.c +++ b/samples/shared-heap/src/main.c @@ -55,7 +55,7 @@ thread1_callback(void *arg) i + 1); printf("wasm app1 send buf: %s\n\n", buf); - if (!bh_post_msg(queue, 1, buf, 1024 * i)) { + if (!bh_post_msg(queue, 1, buf, 1024 * (i + 1))) { printf("Failed to post message to queue\n"); wasm_runtime_shared_heap_free(module_inst, offset); break; @@ -84,7 +84,7 @@ thread1_callback(void *arg) buf = wasm_runtime_addr_app_to_native(module_inst, argv[0]); printf("wasm app1 send buf: %s\n\n", buf); - if (!bh_post_msg(queue, 1, buf, 1024 * i)) { + if (!bh_post_msg(queue, 1, buf, 1024 * (i + 1))) { printf("Failed to post message to queue\n"); wasm_runtime_shared_heap_free(module_inst, argv[0]); break; @@ -251,7 +251,7 @@ main(int argc, char **argv) heap_init_args.size = 65536; shared_heap = wasm_runtime_create_shared_heap(&heap_init_args); if (!shared_heap) { - printf("Create shared heap failed. error: %s\n", error_buf); + printf("Create shared heap failed.\n"); goto fail; } @@ -268,7 +268,7 @@ main(int argc, char **argv) } /* create thread 1 */ - struct thread_arg targ1 = { 0 }; + thread_arg targ1 = { 0 }; korp_tid tid1; targ1.queue = queue; targ1.module_inst = module_inst1; @@ -279,7 +279,7 @@ main(int argc, char **argv) } /* create thread 2 */ - struct thread_arg targ2 = { 0 }; + thread_arg targ2 = { 0 }; korp_tid tid2; targ2.queue = queue; targ2.module_inst = module_inst2; diff --git a/samples/shared-heap/src/shared_heap_chain.c b/samples/shared-heap/src/shared_heap_chain.c new file mode 100644 index 0000000000..f355b5dae2 --- /dev/null +++ b/samples/shared-heap/src/shared_heap_chain.c @@ -0,0 +1,321 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "wasm_export.h" +#include "bh_platform.h" +#include "bh_read_file.h" + +#define BUF_SIZE 4096 +static char preallocated_buf[BUF_SIZE]; + +static bool +produce_data(wasm_module_inst_t module_inst, wasm_exec_env_t exec_env, + bh_queue *queue, wasm_function_inst_t func, uint32 *argv, + uint32 buf_size, bool free_on_fail) +{ + uint8 *buf; + + wasm_runtime_call_wasm(exec_env, func, 2, argv); + + if (wasm_runtime_get_exception(module_inst)) { + printf("Failed to call function: %s\n", + wasm_runtime_get_exception(module_inst)); + return false; + } + if (argv[0] == 0) { + printf("Failed to allocate memory from shared heap\n"); + return false; + } + + buf = wasm_runtime_addr_app_to_native(module_inst, argv[0]); + printf("wasm app1 send buf: %s\n\n", buf); + + /* Passes wasm address directly between wasm apps since memory in shared + * heap chain is viewed as single address space in wasm's perspective */ + buf = (uint8 *)(uintptr_t)argv[0]; + if (!bh_post_msg(queue, 1, buf, buf_size)) { + printf("Failed to post message to queue\n"); + if (free_on_fail) + wasm_runtime_shared_heap_free(module_inst, argv[0]); + return false; + } + + return true; +} + +static void * +wasm_producer(wasm_module_inst_t module_inst, bh_queue *queue) +{ + wasm_exec_env_t exec_env; + wasm_function_inst_t my_shared_heap_malloc_func, my_shared_heap_free_func, + produce_str_func; + uint32 i, argv[2]; + + /* lookup wasm functions */ + if (!(my_shared_heap_malloc_func = wasm_runtime_lookup_function( + module_inst, "my_shared_heap_malloc")) + || !(my_shared_heap_free_func = wasm_runtime_lookup_function( + module_inst, "my_shared_heap_free")) + || !(produce_str_func = + wasm_runtime_lookup_function(module_inst, "produce_str"))) { + printf("Failed to lookup function.\n"); + } + + /* create exec env */ + if (!(exec_env = wasm_runtime_create_exec_env(module_inst, 32768))) { + printf("Failed to create exec env.\n"); + return NULL; + } + + /* allocate memory by calling my_shared_heap_malloc function and send it + to wasm app2 */ + for (i = 0; i < 8; i++) { + argv[0] = 1024 * (i + 1); + argv[1] = i + 1; + if (!produce_data(module_inst, exec_env, queue, + my_shared_heap_malloc_func, argv, 1024 * (i + 1), + true)) { + break; + } + } + + /* use pre-allocated shared heap memory by calling produce_str function and + send it to wasm app2, the pre-allocated shared heap is the last one in + chain, so its end address is calculated from UIN32_MAX */ + uint32 wasm_start_addr = UINT32_MAX - BUF_SIZE + 1; + for (i = 8; i < 16; i++) { + argv[0] = wasm_start_addr + 512 * (i - 8); + argv[1] = i + 1; + if (!produce_data(module_inst, exec_env, queue, produce_str_func, argv, + 512, false)) { + break; + } + } + + wasm_runtime_destroy_exec_env(exec_env); + + return NULL; +} + +static void +wasm_consumer(wasm_module_inst_t module_inst, bh_queue *queue) +{ + wasm_function_inst_t print_buf_func, consume_str_func; + wasm_exec_env_t exec_env; + uint32 argv[2], i; + bh_message_t msg; + char *buf; + + /* lookup wasm function */ + if (!(print_buf_func = + wasm_runtime_lookup_function(module_inst, "print_buf")) + || !(consume_str_func = + wasm_runtime_lookup_function(module_inst, "consume_str"))) { + printf("Failed to lookup function.\n"); + return; + } + + /* create exec env */ + if (!(exec_env = wasm_runtime_create_exec_env(module_inst, 32768))) { + printf("Failed to create exec env.\n"); + return; + } + + for (i = 0; i < 16; i++) { + msg = bh_get_msg(queue, BHT_WAIT_FOREVER); + if (!msg) + return; + buf = bh_message_payload(msg); + + /* call wasm function */ + argv[0] = (uint32)(uintptr_t)buf; + if (i < 8) + wasm_runtime_call_wasm(exec_env, print_buf_func, 1, argv); + else + wasm_runtime_call_wasm(exec_env, consume_str_func, 1, argv); + + if (wasm_runtime_get_exception(module_inst)) { + printf( + "Failed to call 'print_buf' or 'consumer_str' function: %s\n", + wasm_runtime_get_exception(module_inst)); + } + + bh_free_msg(msg); + } + + wasm_runtime_destroy_exec_env(exec_env); +} + +static char global_heap_buf[512 * 1024]; + +int +main(int argc, char **argv) +{ + char *wasm_file1 = NULL, *wasm_file2 = NULL; + uint8 *wasm_file1_buf = NULL, *wasm_file2_buf = NULL; + uint32 wasm_file1_size, wasm_file2_size; + wasm_module_t wasm_module1 = NULL, wasm_module2 = NULL; + wasm_module_inst_t module_inst1 = NULL; + wasm_module_inst_t module_inst2 = NULL; + wasm_shared_heap_t shared_heap = NULL, shared_heap2 = NULL, + shared_heap_chain = NULL; + bh_queue *queue = NULL; + RuntimeInitArgs init_args; + SharedHeapInitArgs heap_init_args; + char error_buf[128] = { 0 }; + bool aot_mode = false; + int ret = -1; + + if (argc > 1 && !strcmp(argv[1], "--aot")) + aot_mode = true; + + if (!aot_mode) + printf("Test shared heap in interpreter mode\n\n"); + else + printf("Test shared heap in AOT mode\n\n"); + + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); + + /* init wasm runtime */ + if (!wasm_runtime_full_init(&init_args)) { + printf("Init runtime environment failed.\n"); + return -1; + } + + /* create queue */ + if (!(queue = bh_queue_create())) { + printf("Create queue failed.\n"); + goto fail; + } + + /* read wasm file */ + if (!aot_mode) + wasm_file1 = "./wasm-apps/test1.wasm"; + else + wasm_file1 = "./wasm-apps/test1_chain.aot"; + if (!(wasm_file1_buf = + bh_read_file_to_buffer(wasm_file1, &wasm_file1_size))) { + printf("Open wasm file %s failed.\n", wasm_file1); + goto fail; + } + + /* load wasm file */ + wasm_module1 = wasm_runtime_load((uint8 *)wasm_file1_buf, wasm_file1_size, + error_buf, sizeof(error_buf)); + if (!wasm_module1) { + printf("Load wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* instantiate module */ + module_inst1 = wasm_runtime_instantiate(wasm_module1, 65536, 0, error_buf, + sizeof(error_buf)); + if (!module_inst1) { + printf("Instantiate wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* read wasm file */ + if (!aot_mode) + wasm_file2 = "./wasm-apps/test2.wasm"; + else + wasm_file2 = "./wasm-apps/test2_chain.aot"; + if (!(wasm_file2_buf = + bh_read_file_to_buffer(wasm_file2, &wasm_file2_size))) { + printf("Open wasm file %s failed.\n", wasm_file1); + goto fail; + } + + /* load wasm file */ + wasm_module2 = wasm_runtime_load((uint8 *)wasm_file2_buf, wasm_file2_size, + error_buf, sizeof(error_buf)); + if (!wasm_module2) { + printf("Load wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* instantiate module */ + module_inst2 = wasm_runtime_instantiate(wasm_module2, 65536, 0, error_buf, + sizeof(error_buf)); + if (!module_inst2) { + printf("Instantiate wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* create shared heap */ + memset(&heap_init_args, 0, sizeof(heap_init_args)); + heap_init_args.size = 65536; + shared_heap = wasm_runtime_create_shared_heap(&heap_init_args); + if (!shared_heap) { + printf("Create shared heap failed.\n"); + goto fail; + } + + /* create a preallocated shared heap */ + memset(&heap_init_args, 0, sizeof(heap_init_args)); + heap_init_args.pre_allocated_addr = preallocated_buf; + heap_init_args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&heap_init_args); + if (!shared_heap2) { + printf("Create preallocated shared heap failed\n"); + goto fail; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + printf("Create shared heap chain failed\n"); + goto fail; + } + + /* attach module instance 1 to the shared heap */ + if (!wasm_runtime_attach_shared_heap(module_inst1, shared_heap_chain)) { + printf("Attach shared heap failed.\n"); + goto fail; + } + + /* attach module instance 2 to the shared heap */ + if (!wasm_runtime_attach_shared_heap(module_inst2, shared_heap_chain)) { + printf("Attach shared heap failed.\n"); + goto fail; + } + + /* wasm 1 produce shared data */ + wasm_producer(module_inst1, queue); + + /* wasm 2 consume shared data */ + wasm_consumer(module_inst2, queue); + ret = 0; + +fail: + if (module_inst2) + wasm_runtime_deinstantiate(module_inst2); + + if (module_inst1) + wasm_runtime_deinstantiate(module_inst1); + + if (wasm_module2) + wasm_runtime_unload(wasm_module2); + + if (wasm_module1) + wasm_runtime_unload(wasm_module1); + + if (wasm_file2_buf) + wasm_runtime_free(wasm_file2_buf); + + if (wasm_file1_buf) + wasm_runtime_free(wasm_file1_buf); + + if (queue) + bh_queue_destroy(queue); + + wasm_runtime_destroy(); + + return ret; +} diff --git a/samples/shared-heap/wasm-apps/CMakeLists.txt b/samples/shared-heap/wasm-apps/CMakeLists.txt index c0010af6a8..7bfa8cd48f 100644 --- a/samples/shared-heap/wasm-apps/CMakeLists.txt +++ b/samples/shared-heap/wasm-apps/CMakeLists.txt @@ -30,9 +30,7 @@ set (CMAKE_EXE_LINKER_FLAGS -Wl,--no-entry,--strip-all, \ -Wl,--export=__heap_base,--export=__data_end \ -Wl,--export=__wasm_call_ctors \ - -Wl,--export=my_shared_heap_malloc \ - -Wl,--export=my_shared_heap_free \ - -Wl,--export=print_buf \ + -Wl,--export-all \ -Wl,--allow-undefined" ) diff --git a/samples/shared-heap/wasm-apps/test1.c b/samples/shared-heap/wasm-apps/test1.c index c8fe0c7553..321f102185 100644 --- a/samples/shared-heap/wasm-apps/test1.c +++ b/samples/shared-heap/wasm-apps/test1.c @@ -58,3 +58,14 @@ my_shared_heap_free(void *ptr) { shared_heap_free(ptr); } + +void * +produce_str(char *addr, uint32_t index) +{ + char c; + snprintf(addr, 512, "Data: %u stores to pre-allocated shared heap", index); + /* Actually access it in wasm */ + c = addr[0]; + printf("In WASM: the first char is %c\n", c); + return addr; +} diff --git a/samples/shared-heap/wasm-apps/test2.c b/samples/shared-heap/wasm-apps/test2.c index b63efcd1a2..44d573164e 100644 --- a/samples/shared-heap/wasm-apps/test2.c +++ b/samples/shared-heap/wasm-apps/test2.c @@ -4,8 +4,7 @@ */ #include - -#include +#include extern void shared_heap_free(void *ptr); @@ -16,3 +15,14 @@ print_buf(char *buf) printf("wasm app2's wasm func received buf: %s\n\n", buf); shared_heap_free(buf); } + +void +consume_str(char *buf) +{ + /* Actually access it in wasm */ + char c = buf[0]; + printf("In WASM: wasm app2's wasm func received buf in pre-allocated " + "shared buf: " + "%s with its first char is %c\n\n", + buf, c); +} diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 8c963cadd8..b726f83a12 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -19,8 +19,15 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") if(WAMR_BUILD_TARGET STREQUAL "X86_32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + # 1) Force -m32 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "" FORCE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "" FORCE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" CACHE STRING "" FORCE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" CACHE STRING "" FORCE) + + # 2) Make CMake prefer i386 libraries + set(CMAKE_SYSTEM_PROCESSOR i386 CACHE STRING "" FORCE) + set(CMAKE_LIBRARY_ARCHITECTURE "i386-linux-gnu" CACHE STRING "" FORCE) endif() # Prevent overriding the parent project's compiler/linker @@ -29,12 +36,21 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Fetch Google test include (FetchContent) -FetchContent_Declare ( + +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24") + FetchContent_Declare ( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + DOWNLOAD_EXTRACT_TIMESTAMP ON + ) +else() + FetchContent_Declare ( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip - DOWNLOAD_EXTRACT_TIMESTAMP TRUE -) -FetchContent_MakeAvailable (googletest) + ) +endif() + +FetchContent_MakeAvailable(googletest) SET(GOOGLETEST_INCLUDED 1) diff --git a/tests/unit/shared-heap/CMakeLists.txt b/tests/unit/shared-heap/CMakeLists.txt index 2b06c537f8..fa7067918a 100644 --- a/tests/unit/shared-heap/CMakeLists.txt +++ b/tests/unit/shared-heap/CMakeLists.txt @@ -12,12 +12,20 @@ set(WAMR_BUILD_AOT 1) set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_FAST_INTERP 1) set(WAMR_BUILD_JIT 0) -set(WAMR_BUILD_MEMORY64 1) +if(WAMR_BUILD_TARGET STREQUAL "X86_32") + set(WAMR_BUILD_MEMORY64 0) +else() + set(WAMR_BUILD_MEMORY64 1) +endif() set(WAMR_BUILD_SHARED_HEAP 1) # Compile wasm modules add_subdirectory(wasm-apps) +if (WAMR_BUILD_MEMORY64 EQUAL 1) + add_subdirectory(wasm-apps/memory64) +endif () + # if only load this CMake other than load it as subdirectory include(../unit_common.cmake) @@ -56,4 +64,4 @@ add_executable(shared_heap_test ${unit_test_sources}) target_link_libraries(shared_heap_test ${LLVM_AVAILABLE_LIBS} gtest_main) -gtest_discover_tests(shared_heap_test) \ No newline at end of file +gtest_discover_tests(shared_heap_test) diff --git a/tests/unit/shared-heap/shared_heap_test.cc b/tests/unit/shared-heap/shared_heap_test.cc index deb4bbb388..47d2eb3e82 100644 --- a/tests/unit/shared-heap/shared_heap_test.cc +++ b/tests/unit/shared-heap/shared_heap_test.cc @@ -9,6 +9,8 @@ #include "bh_read_file.h" #include "wasm_runtime_common.h" +#include + class shared_heap_test : public testing::Test { protected: @@ -26,50 +28,52 @@ struct ret_env { char error_buf[128]; }; -struct ret_env -load_wasm(char *wasm_file_tested, unsigned int app_heap_size) +static void +destroy_module_env(struct ret_env module_env); + +static bool +load_wasm(char *wasm_file_tested, unsigned int app_heap_size, + ret_env &ret_module_env) { - std::string wasm_mem_page = wasm_file_tested; - const char *wasm_file = strdup(wasm_mem_page.c_str()); - wasm_module_inst_t wasm_module_inst = nullptr; - wasm_module_t wasm_module = nullptr; - wasm_exec_env_t exec_env = nullptr; - unsigned char *wasm_file_buf = nullptr; + char *wasm_file = strdup(wasm_file_tested); unsigned int wasm_file_size = 0; unsigned int stack_size = 16 * 1024, heap_size = app_heap_size; char error_buf[128] = { 0 }; - struct ret_env ret_module_env; - memset(ret_module_env.error_buf, 0, 128); - wasm_file_buf = + ret_module_env.wasm_file_buf = (unsigned char *)bh_read_file_to_buffer(wasm_file, &wasm_file_size); - if (!wasm_file_buf) { + if (!ret_module_env.wasm_file_buf) { goto fail; } - wasm_module = wasm_runtime_load(wasm_file_buf, wasm_file_size, error_buf, - sizeof(error_buf)); - if (!wasm_module) { + ret_module_env.wasm_module = + wasm_runtime_load(ret_module_env.wasm_file_buf, wasm_file_size, + error_buf, sizeof(error_buf)); + if (!ret_module_env.wasm_module) { memcpy(ret_module_env.error_buf, error_buf, 128); goto fail; } - wasm_module_inst = wasm_runtime_instantiate( - wasm_module, stack_size, heap_size, error_buf, sizeof(error_buf)); - if (!wasm_module_inst) { + ret_module_env.wasm_module_inst = + wasm_runtime_instantiate(ret_module_env.wasm_module, stack_size, + heap_size, error_buf, sizeof(error_buf)); + if (!ret_module_env.wasm_module_inst) { memcpy(ret_module_env.error_buf, error_buf, 128); goto fail; } - exec_env = wasm_runtime_create_exec_env(wasm_module_inst, stack_size); + ret_module_env.exec_env = wasm_runtime_create_exec_env( + ret_module_env.wasm_module_inst, stack_size); + if (!ret_module_env.exec_env) { + goto fail; + } + free(wasm_file); + return true; fail: - ret_module_env.exec_env = exec_env; - ret_module_env.wasm_module = wasm_module; - ret_module_env.wasm_module_inst = wasm_module_inst; - ret_module_env.wasm_file_buf = wasm_file_buf; - - return ret_module_env; + free(wasm_file); + destroy_module_env(ret_module_env); + return false; } void @@ -92,46 +96,52 @@ destroy_module_env(struct ret_env module_env) } } -static void test_shared_heap(WASMSharedHeap *shared_heap, const char *file, const char *func_name, uint32 argc, uint32 argv[]) +static void +test_shared_heap(WASMSharedHeap *shared_heap, const char *file, + const char *func_name, uint32 argc, uint32 argv[]) { struct ret_env tmp_module_env; WASMFunctionInstanceCommon *func_test = nullptr; bool ret = false; - const char *exception = nullptr; - tmp_module_env = load_wasm((char *)file, 0); + if (!load_wasm((char *)file, 0, tmp_module_env)) { + ADD_FAILURE() << "Failed to load wasm file\n"; + goto fail0; + } - if (!wasm_runtime_attach_shared_heap(tmp_module_env.wasm_module_inst, shared_heap)) { - printf("Failed to attach shared heap\n"); - goto test_failed; + if (!wasm_runtime_attach_shared_heap(tmp_module_env.wasm_module_inst, + shared_heap)) { + ADD_FAILURE() << "Failed to attach shared heap\n"; + goto fail1; } + func_test = wasm_runtime_lookup_function(tmp_module_env.wasm_module_inst, func_name); if (!func_test) { - printf("\nFailed to wasm_runtime_lookup_function!\n"); - goto test_failed; + ADD_FAILURE() << "Failed to wasm_runtime_lookup_function!\n"; + goto fail2; } ret = wasm_runtime_call_wasm(tmp_module_env.exec_env, func_test, argc, argv); if (!ret) { - printf("\nFailed to wasm_runtime_call_wasm!\n"); - const char *s = wasm_runtime_get_exception(tmp_module_env.wasm_module_inst); - printf("exception: %s\n", s); - goto test_failed; + const char *s = + wasm_runtime_get_exception(tmp_module_env.wasm_module_inst); + ADD_FAILURE() << "Failed to wasm_runtime_call_wasm with " + << "exception: " << s; } +fail2: wasm_runtime_detach_shared_heap(tmp_module_env.wasm_module_inst); +fail1: destroy_module_env(tmp_module_env); +fail0: return; -test_failed: - destroy_module_env(tmp_module_env); - EXPECT_EQ(1, 0); } TEST_F(shared_heap_test, test_shared_heap_basic) { - SharedHeapInitArgs args; + SharedHeapInitArgs args = { 0 }; WASMSharedHeap *shared_heap = nullptr; uint32 argv[1] = { 0 }; @@ -139,23 +149,22 @@ TEST_F(shared_heap_test, test_shared_heap_basic) shared_heap = wasm_runtime_create_shared_heap(&args); if (!shared_heap) { - printf("Failed to create shared heap\n"); - EXPECT_EQ(1, 0); + FAIL() << "Failed to create shared heap"; } - // test wasm - test_shared_heap(shared_heap, "test.wasm", "test", 1, argv); + test_shared_heap(shared_heap, "test.wasm", "test", 0, argv); EXPECT_EQ(10, argv[0]); - // test aot - test_shared_heap(shared_heap, "test.aot", "test", 1, argv); + test_shared_heap(shared_heap, "test.aot", "test", 0, argv); EXPECT_EQ(10, argv[0]); + test_shared_heap(shared_heap, "test_chain.aot", "test", 0, argv); + EXPECT_EQ(10, argv[0]); } TEST_F(shared_heap_test, test_shared_heap_malloc_fail) { - SharedHeapInitArgs args; + SharedHeapInitArgs args = { 0 }; WASMSharedHeap *shared_heap = nullptr; uint32 argv[1] = { 0 }; @@ -163,78 +172,880 @@ TEST_F(shared_heap_test, test_shared_heap_malloc_fail) shared_heap = wasm_runtime_create_shared_heap(&args); if (!shared_heap) { - printf("Failed to create shared heap\n"); - EXPECT_EQ(1, 0); + FAIL() << "Failed to create shared heap"; } - // test wasm - test_shared_heap(shared_heap, "test.wasm", "test_malloc_fail", 1, argv); + test_shared_heap(shared_heap, "test.wasm", "test_malloc_fail", 0, argv); EXPECT_EQ(1, argv[0]); - // test aot - test_shared_heap(shared_heap, "test.aot", "test_malloc_fail", 1, argv); + test_shared_heap(shared_heap, "test.aot", "test_malloc_fail", 0, argv); EXPECT_EQ(1, argv[0]); + + test_shared_heap(shared_heap, "test_chain.aot", "test_malloc_fail", 0, + argv); + EXPECT_EQ(1, argv[0]); +} + +TEST_F(shared_heap_test, test_preallocated_shared_heap_malloc_fail) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE]; + + /* create a preallocated shared heap */ + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + /* test wasm can't malloc with preallocated shared heap */ + argv[0] = 1024; + test_shared_heap(shared_heap, "test.wasm", "my_shared_heap_malloc", 1, + argv); + EXPECT_EQ(0, argv[0]); + + argv[0] = 1024; + test_shared_heap(shared_heap, "test.aot", "my_shared_heap_malloc", 1, argv); + EXPECT_EQ(0, argv[0]); + + argv[0] = 1024; + test_shared_heap(shared_heap, "test_chain.aot", "my_shared_heap_malloc", 1, + argv); + EXPECT_EQ(0, argv[0]); +} + +static void +create_test_shared_heap(uint8 *preallocated_buf, size_t size, + WASMSharedHeap **shared_heap_res) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr; + args.pre_allocated_addr = preallocated_buf; + args.size = size; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + *shared_heap_res = shared_heap; + if (!*shared_heap_res) { + FAIL() << "Create shared heap chain failed.\n"; + } +} + +static void +create_test_shared_heap_chain(uint8 *preallocated_buf, size_t size, + uint8 *preallocated_buf2, size_t size2, + WASMSharedHeap **shared_heap_chain) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr; + args.pre_allocated_addr = preallocated_buf; + args.size = size; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf2; + args.size = size2; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + *shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!*shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } +} + +TEST_F(shared_heap_test, test_shared_heap_rmw) +{ + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[2] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE] = { 0 }; + uint32 start1, end1; + + create_test_shared_heap(preallocated_buf, BUF_SIZE, &shared_heap); + + /* app addr for shared heap */ + start1 = UINT32_MAX - BUF_SIZE + 1; + end1 = UINT32_MAX; + + argv[0] = end1; + argv[1] = 101; + test_shared_heap(shared_heap, "test.wasm", "read_modify_write_8", 2, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[BUF_SIZE - 1], 101); + + argv[0] = start1; + argv[1] = 37; + test_shared_heap(shared_heap, "test.wasm", "read_modify_write_8", 2, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[0], 37); + + argv[0] = end1; + argv[1] = 81; + test_shared_heap(shared_heap, "test.aot", "read_modify_write_8", 2, argv); + EXPECT_EQ(101, argv[0]); + EXPECT_EQ(preallocated_buf[BUF_SIZE - 1], 81); + + argv[0] = start1; + argv[1] = 98; + test_shared_heap(shared_heap, "test.aot", "read_modify_write_8", 2, argv); + EXPECT_EQ(37, argv[0]); + EXPECT_EQ(preallocated_buf[0], 98); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_rmw) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[2] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE] = { 0 }, + preallocated_buf2[BUF_SIZE] = { 0 }; + uint32 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT32_MAX - 2 * BUF_SIZE + 1; + end1 = UINT32_MAX - BUF_SIZE; + start2 = UINT32_MAX - BUF_SIZE + 1; + end2 = UINT32_MAX; + + /* shared heap 1 */ + argv[0] = end1; + argv[1] = 101; + test_shared_heap(shared_heap_chain, "test.wasm", "read_modify_write_8", 2, + argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[BUF_SIZE - 1], 101); + + /* shared heap 2 */ + argv[0] = start2; + argv[1] = 129; + test_shared_heap(shared_heap_chain, "test.wasm", "read_modify_write_8", 2, + argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf2[0], 129); + + argv[0] = start1; + argv[1] = 98; + test_shared_heap(shared_heap_chain, "test_chain.aot", "read_modify_write_8", + 2, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[0], 98); + + argv[0] = end2; + argv[1] = 81; + test_shared_heap(shared_heap_chain, "test_chain.aot", "read_modify_write_8", + 2, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf2[BUF_SIZE - 1], 81); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_rmw_bulk_memory) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[3] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE] = { 0 }, + preallocated_buf2[BUF_SIZE] = { 0 }; + uint32 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT32_MAX - 2 * BUF_SIZE + 1; + end1 = UINT32_MAX - BUF_SIZE; + start2 = UINT32_MAX - BUF_SIZE + 1; + end2 = UINT32_MAX; + + argv[0] = end1; + argv[1] = 101; + argv[2] = 1; + test_shared_heap(shared_heap_chain, "test_bulk_memory.wasm", + "memory_fill_test", 3, argv); + /* no modification since no return value */ + EXPECT_EQ(end1, argv[0]); + EXPECT_EQ(preallocated_buf[BUF_SIZE - 1], 101); + + argv[0] = start1; + argv[1] = 14; + argv[2] = 1; + test_shared_heap(shared_heap_chain, "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv); + /* no modification since no return value */ + EXPECT_EQ(start1, argv[0]); + EXPECT_EQ(preallocated_buf[0], 14); + + /* nothing happen when memory fill 0 byte */ + argv[0] = start2; + argv[1] = 68; + argv[2] = 0; + test_shared_heap(shared_heap_chain, "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv); + /* no modification since no return value */ + EXPECT_EQ(start2, argv[0]); + EXPECT_EQ(preallocated_buf2[0], 0); + + argv[0] = end2; + argv[1] = 98; + argv[2] = 1; + test_shared_heap(shared_heap_chain, "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv); + /* no modification since no return value */ + EXPECT_EQ(end2, argv[0]); + EXPECT_EQ(preallocated_buf2[BUF_SIZE - 1], 98); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_rmw_bulk_memory_oob) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[3] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE] = { 0 }, + preallocated_buf2[BUF_SIZE] = { 0 }; + uint32 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT32_MAX - 2 * BUF_SIZE + 1; + end1 = UINT32_MAX - BUF_SIZE; + start2 = UINT32_MAX - BUF_SIZE + 1; + end2 = UINT32_MAX; + + /* shared heap 1 */ + argv[0] = end1; + argv[1] = 101; + argv[2] = 2; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory.wasm", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = end2; + argv[1] = 98; + argv[2] = 2; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory.wasm", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = start1; + argv[1] = 98; + argv[2] = BUF_SIZE + 1; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory.wasm", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = start2; + argv[1] = 98; + argv[2] = BUF_SIZE + 1; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory.wasm", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = end1; + argv[1] = 101; + argv[2] = 2; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = end2; + argv[1] = 98; + argv[2] = 2; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = start1; + argv[1] = 98; + argv[2] = BUF_SIZE + 1; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); + + argv[0] = start2; + argv[1] = 98; + argv[2] = BUF_SIZE + 1; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_bulk_memory_chain.aot", + "memory_fill_test", 3, argv), + "Exception: out of bounds memory access"); +} + +TEST_F(shared_heap_test, test_shared_heap_rmw_oob) +{ + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[2] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE], preallocated_buf2[BUF_SIZE]; + uint32 start1, end1, start2, end2; + + create_test_shared_heap(preallocated_buf, BUF_SIZE, &shared_heap); + + /* app addr for shared heap */ + start1 = UINT32_MAX - BUF_SIZE + 1; + end1 = UINT32_MAX; + + /* try to rmw an u16, first u8 is in the first shared heap and second u8 is + * in the second shared heap, will be seen as oob */ + argv[0] = end1; + argv[1] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, "test.wasm", + "read_modify_write_16", 2, argv), + "Exception: out of bounds memory access"); + + argv[0] = start1 - 1; + argv[1] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, "test.aot", + "read_modify_write_16", 2, argv), + "Exception: out of bounds memory access"); + + argv[0] = end1; + argv[1] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, "test.aot", + "read_modify_write_16", 2, argv), + "Exception: out of bounds memory access"); } +TEST_F(shared_heap_test, test_shared_heap_chain_rmw_oob) +{ + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[2] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE], preallocated_buf2[BUF_SIZE]; + uint32 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT32_MAX - 2 * BUF_SIZE + 1; + end1 = UINT32_MAX - BUF_SIZE; + start2 = UINT32_MAX - BUF_SIZE + 1; + end2 = UINT32_MAX; + + /* try to rmw an u16, first u8 is in the first shared heap and second u8 is + * in the second shared heap, will be seen as oob */ + argv[0] = end2; + argv[1] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, "test.wasm", + "read_modify_write_16", 2, argv), + "Exception: out of bounds memory access"); + + argv[0] = end1; + argv[1] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_chain.aot", + "read_modify_write_16", 2, argv), + "Exception: out of bounds memory access"); +} + +#if WASM_ENABLE_MEMORY64 != 0 +TEST_F(shared_heap_test, test_shared_heap_chain_memory64_rmw) +{ + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[3] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE] = { 0 }, + preallocated_buf2[BUF_SIZE] = { 0 }; + uint64 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT64_MAX - 2 * BUF_SIZE + 1; + end1 = UINT64_MAX - BUF_SIZE; + start2 = UINT64_MAX - BUF_SIZE + 1; + end2 = UINT64_MAX; + + /* shared heap 1 */ + PUT_I64_TO_ADDR(argv, end1); + argv[2] = 101; + test_shared_heap(shared_heap_chain, "test64.wasm", "read_modify_write_8", 3, + argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[BUF_SIZE - 1], 101); + + /* shared heap 2 */ + PUT_I64_TO_ADDR(argv, start2); + argv[2] = 129; + test_shared_heap(shared_heap_chain, "test64.wasm", "read_modify_write_8", 3, + argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf2[0], 129); + + PUT_I64_TO_ADDR(argv, start1); + argv[2] = 98; + test_shared_heap(shared_heap_chain, "test64_chain.aot", + "read_modify_write_8", 3, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf[0], 98); + + PUT_I64_TO_ADDR(argv, end2); + argv[2] = 81; + test_shared_heap(shared_heap_chain, "test64_chain.aot", + "read_modify_write_8", 3, argv); + EXPECT_EQ(0, argv[0]); + EXPECT_EQ(preallocated_buf2[BUF_SIZE - 1], 81); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_memory64_rmw_oob) +{ + WASMSharedHeap *shared_heap_chain = nullptr; + uint32 argv[3] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE], preallocated_buf2[BUF_SIZE]; + uint64 start1, end1, start2, end2; + + create_test_shared_heap_chain(preallocated_buf, BUF_SIZE, preallocated_buf2, + BUF_SIZE, &shared_heap_chain); + + /* app addr for shared heap */ + start1 = UINT64_MAX - 2 * BUF_SIZE + 1; + end1 = UINT64_MAX - BUF_SIZE; + start2 = UINT64_MAX - BUF_SIZE + 1; + end2 = UINT64_MAX; + + /* try to rmw an u16, first u8 is in the first shared heap and second u8 is + * in the second shared heap, will be seen as oob */ + PUT_I64_TO_ADDR(argv, end1); + argv[2] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, "test64.wasm", + "read_modify_write_16", 3, argv), + "Exception: out of bounds memory access"); + + PUT_I64_TO_ADDR(argv, end1); + argv[2] = 12025; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test64_chain.aot", + "read_modify_write_16", 3, argv), + "Exception: out of bounds memory access"); +} +#endif + #ifndef native_function +/* clang-format off */ #define native_function(func_name, signature) \ - { #func_name, (void *)glue_##func_name, signature, NULL } - + { #func_name, (void *)glue_## func_name, signature, NULL } +/* clang-format on */ #endif #ifndef nitems #define nitems(_a) (sizeof(_a) / sizeof(0 [(_a)])) #endif /* nitems */ -uintptr_t glue_test_addr_conv(wasm_exec_env_t env, uintptr_t addr) +uintptr_t +glue_test_addr_conv(wasm_exec_env_t env, uintptr_t addr) { - wasm_module_inst_t module_inst = get_module_inst(env); - uintptr_t ret; - void *native_addr = (void *)addr; - uintptr_t app_addr = addr_native_to_app(native_addr); + wasm_module_inst_t module_inst = get_module_inst(env); + void *native_addr = (void *)addr; + uintptr_t app_addr = addr_native_to_app(native_addr); - native_addr = addr_app_to_native(app_addr); - if (native_addr != (void *)addr) - { - EXPECT_EQ(1, 0); - } - return app_addr; + native_addr = addr_app_to_native(app_addr); + if (native_addr != (void *)addr) { + ADD_FAILURE() << "address conversion incorrect"; + return 0; + } + return app_addr; } -static NativeSymbol g_test_native_symbols[] = -{ - native_function(test_addr_conv,"(*)i"), +static NativeSymbol g_test_native_symbols[] = { + native_function(test_addr_conv, "(*)i"), }; TEST_F(shared_heap_test, test_addr_conv) { - SharedHeapInitArgs args; + SharedHeapInitArgs args = { 0 }; WASMSharedHeap *shared_heap = nullptr; uint32 argv[1] = { 0 }; - struct ret_env tmp_module_env; - WASMFunctionInstanceCommon *func_test = nullptr; bool ret = false; - const char *exception = nullptr; - wasm_module_inst_t module_inst = tmp_module_env.wasm_module_inst; ret = wasm_native_register_natives("env", g_test_native_symbols, nitems(g_test_native_symbols)); - if (!ret) - { - EXPECT_EQ(1, 0); - return; + if (!ret) { + FAIL() << "Failed to register natives"; } args.size = 1024; shared_heap = wasm_runtime_create_shared_heap(&args); if (!shared_heap) { - printf("Failed to create shared heap\n"); - EXPECT_EQ(1, 0); + FAIL() << "Failed to create shared heap"; } - // test wasm - test_shared_heap(shared_heap, "test_addr_conv.wasm", "test", 1, argv); + test_shared_heap(shared_heap, "test_addr_conv.wasm", "test", 0, argv); + EXPECT_EQ(1, argv[0]); + + test_shared_heap(shared_heap, "test_addr_conv.aot", "test", 0, argv); EXPECT_EQ(1, argv[0]); - // test aot - test_shared_heap(shared_heap, "test_addr_conv.aot", "test", 1, argv); + test_shared_heap(shared_heap, "test_addr_conv_chain.aot", "test", 0, argv); EXPECT_EQ(1, argv[0]); } + +TEST_F(shared_heap_test, test_addr_conv_pre_allocated_oob) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(), + app_addr = 0xFFFFFFFF - BUF_SIZE; + uint8 preallocated_buf[BUF_SIZE]; + bool ret = false; + + /* create a preallocated shared heap */ + ret = wasm_native_register_natives("env", g_test_native_symbols, + nitems(g_test_native_symbols)); + if (!ret) { + FAIL() << "Failed to register natives"; + } + + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + argv[0] = app_addr; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, "test_addr_conv.wasm", + "test_preallocated", 1, argv), + "Exception: out of bounds memory access"); + + argv[0] = app_addr; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, "test_addr_conv.aot", + "test_preallocated", 1, argv), + "Exception: out of bounds memory access"); + + argv[0] = app_addr; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap, + "test_addr_conv_chain.aot", + "test_preallocated", 1, argv), + "Exception: out of bounds memory access"); +} + +TEST_F(shared_heap_test, test_shared_heap_chain) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE]; + bool ret = false; + + ret = wasm_native_register_natives("env", g_test_native_symbols, + nitems(g_test_native_symbols)); + if (!ret) { + FAIL() << "Failed to register natives"; + } + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + /* create a preallocated shared heap */ + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } + + test_shared_heap(shared_heap_chain, "test_addr_conv.wasm", "test", 0, argv); + EXPECT_EQ(1, argv[0]); + + test_shared_heap(shared_heap, "test_addr_conv.aot", "test", 0, argv); + EXPECT_EQ(1, argv[0]); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_create_fail) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap_chain = nullptr; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + args.size = 4096; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + EXPECT_EQ(shared_heap_chain, nullptr); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_create_fail2) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE]; + struct ret_env tmp_module_env; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + if (!load_wasm((char *)"test.wasm", 0, tmp_module_env)) { + FAIL() << "Failed to load wasm file\n"; + } + + if (!wasm_runtime_attach_shared_heap(tmp_module_env.wasm_module_inst, + shared_heap)) { + FAIL() << "Failed to attach shared heap\n"; + } + + /* can't create shared heap chain when shared heap is attached to a wasm + * app */ + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + EXPECT_EQ(shared_heap_chain, nullptr); + + wasm_runtime_detach_shared_heap(tmp_module_env.wasm_module_inst); + destroy_module_env(tmp_module_env); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_create_fail3) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap3 = nullptr, *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE], preallocated_buf2[BUF_SIZE]; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf2; + args.size = BUF_SIZE; + shared_heap3 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap3) { + FAIL() << "Failed to create shared heap"; + } + + /* The head and body can't be already in other shared heap chain as body */ + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap3, shared_heap2); + EXPECT_EQ(shared_heap_chain, nullptr); + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap2, shared_heap); + EXPECT_EQ(shared_heap_chain, nullptr); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_unchain) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap3 = nullptr, *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE], preallocated_buf2[BUF_SIZE]; + + args.size = 1024; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } + + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf2; + args.size = BUF_SIZE; + shared_heap3 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap3) { + FAIL() << "Failed to create shared heap"; + } + + /* unchain shared heap so that the 'body' can be another chain 'body' + * again(1->2 to 1->3->2) */ + EXPECT_EQ(shared_heap2, + wasm_runtime_unchain_shared_heaps(shared_heap_chain, false)); + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap3, shared_heap2); + EXPECT_EQ(shared_heap_chain, shared_heap3); + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap3); + EXPECT_EQ(shared_heap, shared_heap_chain); + + /* break down the entire shared heap chain */ + EXPECT_EQ(shared_heap2, + wasm_runtime_unchain_shared_heaps(shared_heap_chain, true)); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_addr_conv) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE]; + bool ret = false; + + ret = wasm_native_register_natives("env", g_test_native_symbols, + nitems(g_test_native_symbols)); + if (!ret) { + FAIL() << "Failed to register natives"; + } + + args.size = 4096; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + /* create a preallocated shared heap */ + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } + + argv[0] = 0xFFFFFFFF; + test_shared_heap(shared_heap_chain, "test_addr_conv.wasm", + "test_preallocated", 1, argv); + EXPECT_EQ(1, argv[0]); + + argv[0] = 0xFFFFF000; + test_shared_heap(shared_heap_chain, "test_addr_conv.wasm", + "test_preallocated", 1, argv); + EXPECT_EQ(1, argv[0]); + + argv[0] = 0xFFFFFFFF; + test_shared_heap(shared_heap, "test_addr_conv_chain.aot", + "test_preallocated", 1, argv); + EXPECT_EQ(1, argv[0]); + + argv[0] = 0xFFFFF000; + test_shared_heap(shared_heap, "test_addr_conv_chain.aot", + "test_preallocated", 1, argv); + EXPECT_EQ(1, argv[0]); +} + +TEST_F(shared_heap_test, test_shared_heap_chain_addr_conv_oob) +{ + SharedHeapInitArgs args = { 0 }; + WASMSharedHeap *shared_heap = nullptr, *shared_heap2 = nullptr, + *shared_heap_chain = nullptr; + uint32 argv[1] = { 0 }, BUF_SIZE = os_getpagesize(); + uint8 preallocated_buf[BUF_SIZE]; + bool ret = false; + + ret = wasm_native_register_natives("env", g_test_native_symbols, + nitems(g_test_native_symbols)); + if (!ret) { + FAIL() << "Failed to register natives"; + } + + args.size = 4096; + shared_heap = wasm_runtime_create_shared_heap(&args); + if (!shared_heap) { + FAIL() << "Failed to create shared heap"; + } + + /* create a preallocated shared heap */ + memset(&args, 0, sizeof(args)); + args.pre_allocated_addr = preallocated_buf; + args.size = BUF_SIZE; + shared_heap2 = wasm_runtime_create_shared_heap(&args); + if (!shared_heap2) { + FAIL() << "Create preallocated shared heap failed.\n"; + } + + shared_heap_chain = + wasm_runtime_chain_shared_heaps(shared_heap, shared_heap2); + if (!shared_heap_chain) { + FAIL() << "Create shared heap chain failed.\n"; + } + + /* test wasm */ + argv[0] = 0xFFFFFFFF - BUF_SIZE - 4096; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_addr_conv.wasm", + "test_preallocated", 1, argv), + "Exception: out of bounds memory access"); + + /* test aot */ + argv[0] = 0xFFFFFFFF - BUF_SIZE - 4096; + EXPECT_NONFATAL_FAILURE(test_shared_heap(shared_heap_chain, + "test_addr_conv_chain.aot", + "test_preallocated", 1, argv), + "Exception: out of bounds memory access"); +} diff --git a/tests/unit/shared-heap/wasm-apps/CMakeLists.txt b/tests/unit/shared-heap/wasm-apps/CMakeLists.txt index 097f66ae5d..985cf18aeb 100644 --- a/tests/unit/shared-heap/wasm-apps/CMakeLists.txt +++ b/tests/unit/shared-heap/wasm-apps/CMakeLists.txt @@ -29,44 +29,81 @@ set(CMAKE_EXE_LINKER_FLAGS -Wl,--allow-undefined" ) -add_executable(test.wasm test.c) -target_link_libraries(test.wasm) +if (WAMR_BUILD_TARGET STREQUAL "X86_32") + set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap --target=i386) + set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain --target=i386) +else () + set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap) + set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain) +endif () -add_custom_command(TARGET test.wasm POST_BUILD +function(copy_wasm TARGET_NAME) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/test.wasm - ${CMAKE_CURRENT_BINARY_DIR}/../ - COMMENT "Copy test.wasm to the same directory of google test" - ) + ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMENT "Copy ${TARGET_NAME} to the same directory of google test" + ) +endfunction() + +function(compile_and_copy_aot_from TARGET_NAME) + string(REPLACE ".wasm" ".aot" AOT_TARGET ${TARGET_NAME}) + string(REPLACE ".wasm" "_chain.aot" AOT_CHAIN_TARGET ${TARGET_NAME}) -add_custom_command(TARGET test.wasm POST_BUILD - COMMAND ${WAMRC_ROOT_DIR}/wamrc --opt-level=0 --enable-shared-heap --bounds-checks=1 - -o - test.aot - test.wasm + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS} + -o ${AOT_TARGET} + ${TARGET_NAME} COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/test.aot - ${CMAKE_CURRENT_BINARY_DIR}/../ - COMMENT "Copy test.aot to the same directory of google test" - ) + ${CMAKE_CURRENT_BINARY_DIR}/${AOT_TARGET} + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS} + -o ${AOT_CHAIN_TARGET} + ${TARGET_NAME} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/${AOT_CHAIN_TARGET} + ${CMAKE_CURRENT_BINARY_DIR}/../ + COMMENT "Compile and copy ${AOT_TARGET} to the same directory of google test" + ) +endfunction() -add_executable(test_addr_conv.wasm test_addr_conv.c) +add_executable(test.wasm test.c) target_link_libraries(test.wasm) +copy_wasm(test.wasm) +compile_and_copy_aot_from(test.wasm) -add_custom_command(TARGET test_addr_conv.wasm POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.wasm - ${CMAKE_CURRENT_BINARY_DIR}/../ - COMMENT "Copy test_addr_conv.wasm to the same directory of google test" - ) +add_executable(test_addr_conv.wasm test_addr_conv.c) +target_link_libraries(test_addr_conv.wasm) +copy_wasm(test_addr_conv.wasm) +compile_and_copy_aot_from(test_addr_conv.wasm) -add_custom_command(TARGET test_addr_conv.wasm POST_BUILD - COMMAND ${WAMRC_ROOT_DIR}/wamrc --opt-level=0 --enable-shared-heap --bounds-checks=1 - -o - test_addr_conv.aot - test_addr_conv.wasm - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/test_addr_conv.aot - ${CMAKE_CURRENT_BINARY_DIR}/../ - COMMENT "Copy test_addr_conv.aot to the same directory of google test" - ) +# copy and compile aot for bulk memory test +set(SOURCE_WASM ${CMAKE_CURRENT_SOURCE_DIR}/bulk-memory/test_bulk_memory.wasm) +set(BUILD_WASM ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory.wasm) +set(OUTPUT_AOT ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory.aot) +set(OUTPUT_CHAIN_AOT ${CMAKE_CURRENT_BINARY_DIR}/../test_bulk_memory_chain.aot) + +add_custom_command( + OUTPUT ${BUILD_WASM} + COMMAND ${CMAKE_COMMAND} -E copy + ${SOURCE_WASM} + ${BUILD_WASM} + DEPENDS ${SOURCE_WASM} + COMMENT "Copying bulk memory WASM to build directory" +) + +add_custom_command( + OUTPUT ${OUTPUT_AOT} + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS} + -o ${OUTPUT_AOT} + ${BUILD_WASM} + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS} + -o ${OUTPUT_CHAIN_AOT} + ${BUILD_WASM} + DEPENDS ${BUILD_WASM} + COMMENT "Compiling bulk memory AOT from copied WASM" +) + +add_custom_target(compile_bulk_memory_aot ALL + DEPENDS ${OUTPUT_AOT} +) diff --git a/tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wasm b/tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wasm new file mode 100644 index 0000000000000000000000000000000000000000..eb3d60be3da992383bd142c229388824ba10439d GIT binary patch literal 63 zcmZQbEY4+QU|?WmXG~zOudiodW@2PuWo85lh%gG|rsn1sRmP`f=H$eeq!yPjFmUlQ Rax*9}C@?B8{o!Wd1^{Vt3%&pV literal 0 HcmV?d00001 diff --git a/tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wat b/tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wat new file mode 100644 index 0000000000..e7a0c684d1 --- /dev/null +++ b/tests/unit/shared-heap/wasm-apps/bulk-memory/test_bulk_memory.wat @@ -0,0 +1,12 @@ +(module + (memory 1) + + (func $memory_fill_test (param $dst i32) (param $val i32) (param $len i32) + local.get $dst + local.get $val + local.get $len + memory.fill + ) + + (export "memory_fill_test" (func $memory_fill_test)) +) diff --git a/tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt b/tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt new file mode 100644 index 0000000000..a82788b586 --- /dev/null +++ b/tests/unit/shared-heap/wasm-apps/memory64/CMakeLists.txt @@ -0,0 +1,68 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.14) +project(wasm-apps-wasm64) + +set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..) +set(WAMRC_ROOT_DIR ${WAMR_ROOT_DIR}/wamr-compiler/build) + +set(CMAKE_SYSTEM_PROCESSOR wasm64) +set(CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot) + +if (NOT DEFINED WASI_SDK_DIR) + set(WASI_SDK_DIR "/opt/wasi-sdk") +endif () + +set(CMAKE_C_FLAGS "-nostdlib -pthread -Qunused-arguments") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z stack-size=8192 -nostdlib -O0 --target=wasm64") +set(CMAKE_C_COMPILER_TARGET "wasm64") +set(CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang") + +set(DEFINED_SYMBOLS + "${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt") + +set(CMAKE_EXE_LINKER_FLAGS + "-Wl,--no-entry \ + -Wl,--initial-memory=65536 \ + -Wl,--export-all \ + -Wl,--allow-undefined" + ) + +set (WAMR_COMPILER_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-heap) +set (WAMR_COMPILER_CHAIN_FLAGS --opt-level=3 --bounds-checks=1 --enable-shared-chain) + +function(copy_wasm TARGET_NAME) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + ${CMAKE_CURRENT_BINARY_DIR}/../../ + COMMENT "Copy ${TARGET_NAME} to the same directory of google test" + ) +endfunction() + +function(compile_and_copy_aot_from TARGET_NAME) + string(REPLACE ".wasm" ".aot" AOT_TARGET ${TARGET_NAME}) + string(REPLACE ".wasm" "_chain.aot" AOT_CHAIN_TARGET ${TARGET_NAME}) + + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_FLAGS} + -o ${AOT_TARGET} + ${TARGET_NAME} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/${AOT_TARGET} + ${CMAKE_CURRENT_BINARY_DIR}/../../ + COMMAND ${WAMRC_ROOT_DIR}/wamrc ${WAMR_COMPILER_CHAIN_FLAGS} + -o ${AOT_CHAIN_TARGET} + ${TARGET_NAME} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/${AOT_CHAIN_TARGET} + ${CMAKE_CURRENT_BINARY_DIR}/../../ + COMMENT "Compile and copy ${AOT_TARGET} ${AOT_CHAIN_TARGET} to the same directory of google test" + ) +endfunction() + +add_executable(test64.wasm ../test.c) +target_link_libraries(test64.wasm) +copy_wasm(test64.wasm) +compile_and_copy_aot_from(test64.wasm) diff --git a/tests/unit/shared-heap/wasm-apps/test.c b/tests/unit/shared-heap/wasm-apps/test.c index bd0df19c20..66df21c1b7 100644 --- a/tests/unit/shared-heap/wasm-apps/test.c +++ b/tests/unit/shared-heap/wasm-apps/test.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -#include +#define NULL 0 extern void * shared_heap_malloc(int size); @@ -32,3 +32,31 @@ test_malloc_fail() shared_heap_free(ptr); return 0; } + +void * +my_shared_heap_malloc(int size) +{ + return shared_heap_malloc(size); +} + +void +my_shared_heap_free(void *addr) +{ + shared_heap_free(addr); +} + +char +read_modify_write_8(char *addr, char value) +{ + char original_value = *addr; + *addr = value; + return original_value; +} + +short +read_modify_write_16(short *addr, short value) +{ + short original_value = *addr; + *addr = value; + return original_value; +} diff --git a/tests/unit/shared-heap/wasm-apps/test_addr_conv.c b/tests/unit/shared-heap/wasm-apps/test_addr_conv.c index f91764c84c..5e64526a04 100644 --- a/tests/unit/shared-heap/wasm-apps/test_addr_conv.c +++ b/tests/unit/shared-heap/wasm-apps/test_addr_conv.c @@ -30,3 +30,17 @@ test() shared_heap_free(ptr); return 1; } + +int +test_preallocated(void *app_addr) +{ + int *ptr = (int *)app_addr; + int *ptr2 = NULL; + + ptr2 = test_addr_conv(ptr); + if (ptr2 != ptr) { + return 0; + } + + return 1; +} diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 0ce6473944..68648b84b7 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -284,6 +284,7 @@ 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) +include (${IWASM_DIR}/libraries/shared-heap/shared_heap.cmake) if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake) @@ -366,6 +367,7 @@ add_library (vmlib ${LIBC_WASI_SOURCE} ${LIB_PTHREAD_SOURCE} ${LIB_WASI_THREADS_SOURCE} + ${LIB_SHARED_HEAP_SOURCE} ${IWASM_COMMON_SOURCE} ${IWASM_INTERP_SOURCE} ${IWASM_AOT_SOURCE} diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c index c9c4ac5da3..8f029f79b2 100644 --- a/wamr-compiler/main.c +++ b/wamr-compiler/main.c @@ -213,7 +213,9 @@ print_help() printf(" --enable-linux-perf Enable linux perf support\n"); #endif printf(" --mllvm=