From 7a0a5d3171373813cc99d26f5ef4e5b76b444a91 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 001/264] 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 3f58f07da31c464a9d408fcbd75bd1aee6583cbf 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 002/264] 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 9cea6df28bdc806facb05fbd614b5c2e728dd030 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 003/264] 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 d2c06f7dd64b796cfb57f3132a2a68d8d85d0c48 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 004/264] 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 a1e30e3a3b568b0b1aa6fb2c06218b23ba14bced Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Dec 2024 17:49:25 +0900 Subject: [PATCH 005/264] 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 4d769641a5f1d65fe96e256b6f3c73dfce3653e2 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 19 Dec 2024 16:49:44 +0800 Subject: [PATCH 006/264] 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 d81020ae66052fbf4e86f420350daf85b01f05ff Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 19 Dec 2024 16:51:20 +0800 Subject: [PATCH 007/264] [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 2fdcd4b95166452a0a74a92f3c55481586d7c738 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 008/264] 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 0c73ec1be57905d41db0e99879efafbd64f50813 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 009/264] 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 3cea4a2f809b359400329bad20c43928f64d698b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Dec 2024 14:38:48 +0900 Subject: [PATCH 010/264] 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 1d8a765f25c1be578e28c9aa6fcfeff5a49e3f82 Mon Sep 17 00:00:00 2001 From: James Ring Date: Mon, 23 Dec 2024 15:25:52 -0800 Subject: [PATCH 011/264] 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 bf0afc2ef9e897952b101bb1a9eba15be579eaa0 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 24 Dec 2024 20:19:40 +0800 Subject: [PATCH 012/264] 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 dcfdfa67b42893297821776d769c2a29437f1587 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 013/264] 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 1d44a88d5ba22812f3584ec1ba2d866f793c5652 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 014/264] 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 26b22efafa60bb5bdc1b75ac3df6078162b2620c Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 26 Dec 2024 15:15:25 +0800 Subject: [PATCH 015/264] 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 69dd9d129327a4d825e77e801dedc31a39fbc3bd Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 25 Dec 2024 21:46:48 +0800 Subject: [PATCH 016/264] 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 699f3c875e..81fdb1284f 100644 --- a/core/iwasm/compilation/aot.c +++ b/core/iwasm/compilation/aot.c @@ -502,60 +502,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; @@ -563,7 +573,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); @@ -595,22 +605,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++) { @@ -656,64 +674,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; @@ -732,6 +836,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 cf54da33428e05710d72cfb3a522c3528aacebbd Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Sun, 29 Dec 2024 15:52:12 +0800 Subject: [PATCH 017/264] 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 4377fd01f03aa231a439cb810f21edeee021fe51 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Fri, 3 Jan 2025 02:44:25 +0000 Subject: [PATCH 018/264] 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 4b212e76303cac29fd5d2569cee51413b7960aab Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 3 Jan 2025 14:37:09 +0800 Subject: [PATCH 019/264] 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 ae70dbd1f0b004852be4509303de810477131877 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Sun, 5 Jan 2025 15:27:40 +0800 Subject: [PATCH 020/264] 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 76344d33f175438561d2e1c83224db4e77083002 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 021/264] 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 bb930a4dc7e34d480c0999937ade44176fcfa3ab Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 6 Jan 2025 11:36:11 +0800 Subject: [PATCH 022/264] [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 10b27e8eecc2f2341326bd24193b6ee08be1e049 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 023/264] 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 ab92fb1aa772d36abe8dd5162328b836e58b05b6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 9 Jan 2025 13:11:25 +0800 Subject: [PATCH 024/264] 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 02d5cf33a1f01b2f52f34854f121f186bb05f022 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 9 Jan 2025 13:13:30 +0800 Subject: [PATCH 025/264] 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 82383833df9082325ac0256ecbc861d4d3fa3ba1 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 13 Jan 2025 07:09:04 +0800 Subject: [PATCH 026/264] 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 244df46994e9ec09844fc2ff792f9f46d2e80dce 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 027/264] 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 a035f60d7e30b82bd433385ce0a60e7a5f318e06 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 028/264] 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 539d19714f04dc6da74e92022ef765962ecfa31e Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 14 Jan 2025 17:43:29 +0800 Subject: [PATCH 029/264] 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 55b49d76cad1d438fbf1aafe51c551b3fe5f0c29 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 030/264] .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 62766723fd700b9e66398898ee86d4816d784eca 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 031/264] 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 3e26320f75fdd4d6202bfa88e3a6e735f37e9e25 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 20 Jan 2025 09:39:32 +0800 Subject: [PATCH 032/264] 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 98c6dd7a9224d600f2d2ebafc080513ccd7ac660 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 20 Jan 2025 09:41:47 +0800 Subject: [PATCH 033/264] 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 a3ef93317cb7f1465581003c00db30baa48e1fc1 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 034/264] 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 4eb9ed0017785acd5dc86154645079d0a84fb2f4 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 035/264] 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 70edf99709ac7144387522ec3de25c8fddfa158a 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 036/264] 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 621d135fe0128481656127da623c90b40a05961b 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 037/264] 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 0e0bbccb14b56265de17fb5acc9056c4d118a72b Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Wed, 5 Feb 2025 03:31:49 +0000 Subject: [PATCH 038/264] 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 751af39ff8d3b93c0fd3dda4d1aab442b23a1689 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 5 Feb 2025 15:21:49 +0800 Subject: [PATCH 039/264] 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 90010a0d8103215f0ec30c2997af73c508c1b258 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 5 Feb 2025 15:28:26 +0800 Subject: [PATCH 040/264] 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 314fdfb0324bd2e3faf0d4be906c24bcfc8771fc Mon Sep 17 00:00:00 2001 From: Viacheslav Palchikov Date: Thu, 30 Jan 2025 01:15:14 +0300 Subject: [PATCH 041/264] 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 957f36d11b26b2f8945458562de1de41e22828d3 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 26 Nov 2024 03:39:03 +0000 Subject: [PATCH 042/264] 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 cb57dfb8700ae568548bc5b8e9efc0a6b6b70b76 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 24 Dec 2024 02:01:18 +0000 Subject: [PATCH 043/264] 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 07618878f971dcf964dfd3eefc83f99bb578e3ee Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Thu, 26 Dec 2024 00:56:22 +0000 Subject: [PATCH 044/264] 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 caa0b85c712f4e4105e9c3ee66d0773a48b2574f Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Fri, 10 Jan 2025 08:03:32 +0000 Subject: [PATCH 045/264] 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 a8b5d9f4d68375ae0d1d26d9e39dfb245461e6cb Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Fri, 17 Jan 2025 04:05:05 +0000 Subject: [PATCH 046/264] 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 5e71525092999020dd79f242363abbb446ac7b5d Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Jan 2025 03:16:10 +0000 Subject: [PATCH 047/264] 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 9a39ea18aae166ffca606423f1b200bc68012f5e Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 21 Jan 2025 01:49:29 +0000 Subject: [PATCH 048/264] 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 4b5db39fda746ca173ba6813ef8ef6a8f113574d Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 13:15:00 +0800 Subject: [PATCH 049/264] 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 adb1ac26701ee01f6727111eee5b3cd784a2c0e7 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 13:15:56 +0800 Subject: [PATCH 050/264] [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 25859899f9f2897e3cfd68cf58cc0e8fa9a955fe 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 051/264] 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 d7f6b5eb3522785e537d219b2578485c59792a5c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 20:05:33 +0800 Subject: [PATCH 052/264] 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 a2ed2ccc98c887206eb5f2c3831303754aee8b70 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 053/264] 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 dbd9de8b74b525cd3ec88640d5e1143f4765db79 Mon Sep 17 00:00:00 2001 From: yangkun27 Date: Fri, 14 Feb 2025 16:13:00 +0800 Subject: [PATCH 054/264] 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 371b597b66ab10bd96758e63e05d2bb82b782251 Mon Sep 17 00:00:00 2001 From: yangkun27 Date: Fri, 14 Feb 2025 16:13:15 +0800 Subject: [PATCH 055/264] 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 041d2889c09ad9016612c132bb2671f8c04ad724 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 14 Feb 2025 16:15:45 +0800 Subject: [PATCH 056/264] 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 93841bd1930bac1615a1691af91c9f659758d016 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 057/264] [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 80a49fca87b3f536ea054f91bf51ea8cd7689709 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Sat, 15 Feb 2025 16:25:06 +0800 Subject: [PATCH 058/264] 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 3c3f13330e6d1ae2d53014e366f9ef56669ab2d5 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 17 Feb 2025 13:34:18 +0800 Subject: [PATCH 059/264] 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 2643e12121c3a39a32ad7d008588948acc687697 Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Mon, 17 Feb 2025 06:34:40 +0100 Subject: [PATCH 060/264] 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 4635ce6428bd854179886c851b424a81d9e97028 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 17 Feb 2025 12:23:04 +0800 Subject: [PATCH 061/264] 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 88959d84e51ffc1d1e031085d6bbfdb242c00035 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 21 Feb 2025 07:46:20 +0800 Subject: [PATCH 062/264] 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 acf9a8e58725033d41923dd7460e2b0037dc3070 Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Fri, 21 Feb 2025 08:29:49 +0100 Subject: [PATCH 063/264] 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 98e46e86910a46a2aa125afcfd62e1d736b4d0be Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 21 Feb 2025 15:33:36 +0800 Subject: [PATCH 064/264] 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 f4ee294671f56d1bb9682ea781be744b26c9fd1e Mon Sep 17 00:00:00 2001 From: TL Date: Sat, 8 Feb 2025 17:18:01 +0800 Subject: [PATCH 065/264] 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 74ebc5fd898c414c276df6c664faa56126fb5a5a Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:41:34 +0800 Subject: [PATCH 066/264] 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 b73cdf05b442f69dacb70faf56e670f833ae6233 Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:42:25 +0800 Subject: [PATCH 067/264] 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 67a0287404fd20331ede37fbceadbff6218ceb26 Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:47:52 +0800 Subject: [PATCH 068/264] 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 75dd4fac3a1aea46d1a96e1c0bb6f4b0c8c23555 Mon Sep 17 00:00:00 2001 From: TL Date: Tue, 18 Feb 2025 16:35:42 +0800 Subject: [PATCH 069/264] 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 35b295c0890e714456cc089ef56b75ecf788f0cc 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 070/264] 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 e60660326009614be9551a5c9cb719350f2dedef 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 071/264] 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 0eba49aa48f113fb99c12d43b796c1bd5d81526c 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 072/264] 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 16d267d8f70d8ae138cf0961636b73ad888c4bfa Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 25 Feb 2025 06:49:37 +0800 Subject: [PATCH 073/264] 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 0d70b0b7ba10906904b0b712867cf1ade92ee913 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 074/264] 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 e33a036ab15a91f57c298ffa2aec350eb67defdd 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 075/264] 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 78280b98ca0ecd839e3ddc7f4580275627b9d1d4 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 26 Feb 2025 12:58:45 +0800 Subject: [PATCH 076/264] 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 e90a056a86149b0fd232fea974b8b104a35c6ffd 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 077/264] 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 ef30902b57d9cc44a6245a671d190309f510deb5 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 078/264] 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 177a480f658746a5e395bb2aa55ef59e4bc014ee Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 7 Mar 2025 08:21:54 +0800 Subject: [PATCH 079/264] 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 0645ac0aae..6d9cbaef6b 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 f5d30094a1ad3b15c337c228ce9b87c77979da41 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 080/264] 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 c6a7587f3edec0f6d71058422b159203dab5a9ff Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Fri, 17 Jan 2025 16:16:45 +0000 Subject: [PATCH 081/264] 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 18a098a455..1b7d87419e 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 95cea7fe9b..747c6fa4a6 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 17beb3ad74..1d0189bd07 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 d504e984c8..ab22dfce43 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 96b9ba2b21..4326b2a930 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]; @@ -6034,6 +6036,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 18c56417e7..9438c34269 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 ad8f72c69d88f010fc0dfb6e578ace030e5e156b Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:28:30 +0000 Subject: [PATCH 082/264] 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 1b7d87419e..0baae67b66 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 ec9441d5b553ef375167b9be7bba9c890e868578 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:31:02 +0000 Subject: [PATCH 083/264] 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 0baae67b66..cf7455367f 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 747c6fa4a6..b2e2e639f6 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 1d0189bd07..a04d6bef8f 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 9438c34269..3644240436 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 a63be1c21b97d4f023a31b9bc1aa08f4134a1813 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:35:56 +0000 Subject: [PATCH 084/264] 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 a04d6bef8f..05f994b510 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 dd8fee7b2433da60c37f75866a9d7d68208df371 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:39:53 +0000 Subject: [PATCH 085/264] 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 b2e2e639f6..ef7973544a 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 05f994b510..e191a6b24f 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 2e134394c37e188cee5f71a02bf75dbd37b628f4 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:42:12 +0000 Subject: [PATCH 086/264] 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 e191a6b24f..9095eab961 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 08ecafb52caf496fd1b596889416c1a691aaa4d1 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 15:08:03 +0000 Subject: [PATCH 087/264] 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 cf7455367f..3bd9b6d905 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 78dca502feb9e3855df8e19c70f5759d50f13480 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 15:08:58 +0000 Subject: [PATCH 088/264] 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 3bd9b6d905..da37347038 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 792cb52f487e02c13e9efe8abf72f5a2017d1a9d Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:09:32 +0000 Subject: [PATCH 089/264] 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 ab22dfce43..d504e984c8 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 4326b2a930..96b9ba2b21 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]; @@ -6036,7 +6034,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 3644240436..1c2d000d6d 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 a4f647680b023e166092d5beb7064f9743bb6b04 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:25:45 +0000 Subject: [PATCH 090/264] 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 1c2d000d6d..17f60cbe0e 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 ca9e2c4604a029c4941dbe079467a93675c77b3d Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:36:59 +0000 Subject: [PATCH 091/264] 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 da37347038..d00af5c9fe 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 d66287108c9f3ab01f1142de07c0ae588c7a5363 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 13:27:01 +0000 Subject: [PATCH 092/264] 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 17f60cbe0e..9dd68cca02 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 e0dce76e2aa2dd1e84aba6f7551ac2c285ee5a8c Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 16:14:01 +0000 Subject: [PATCH 093/264] 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 d00af5c9fe..27763ab21d 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 866a6264a656f70ff11d329f0499f5a43cbbb55e Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 16:33:52 +0000 Subject: [PATCH 094/264] 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 27763ab21d..f5a135be95 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 35f8121f9255438a06d0113690d270e19c0eb53d Mon Sep 17 00:00:00 2001 From: "Georgii Rylov :slightly_smiling_face" Date: Mon, 24 Feb 2025 17:22:05 +0000 Subject: [PATCH 095/264] 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 e52c86cf27..e6d1c840a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,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 614830094a..bba0c9a52b 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -324,6 +324,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 ef7973544a..729ab40233 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 9095eab961..66d31939c6 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 115901b0ec18045b68caa914b701410ffbc03af4 Mon Sep 17 00:00:00 2001 From: "Georgii Rylov :slightly_smiling_face" Date: Mon, 24 Feb 2025 17:33:14 +0000 Subject: [PATCH 096/264] 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 bba0c9a52b..312944be59 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -326,10 +326,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 729ab40233..4bb4d94a5e 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 66d31939c6..7414288dc3 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 1e435e27f49bce1c361a8428e98d530f0db8b44e Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 25 Feb 2025 17:42:06 +0000 Subject: [PATCH 097/264] 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 4bb4d94a5e..a3a0becec1 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 1a8879144dd764412326b1dc8bbf17bd5dc306bf Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 10:57:50 +0000 Subject: [PATCH 098/264] 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 a3a0becec1..5ccd0cd712 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 7414288dc3..26f4ffed25 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 48d28d6ea20c183892bed0c88c171d391a24bc2b Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 11:11:17 +0000 Subject: [PATCH 099/264] 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 58475ccd788beb96fb83c8712f282fc2cd1f4555 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 11:22:31 +0000 Subject: [PATCH 100/264] 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 20d799f17923552aa857f383fea3dd593e996bdf Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 14:32:17 +0000 Subject: [PATCH 101/264] 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 5ccd0cd712..735e7c6a59 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 26f4ffed25..b73a0364e7 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 fed3b350c3f6ef8e8407dcd80da34d84c6ac59e4 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 14:35:53 +0000 Subject: [PATCH 102/264] 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 9e2230576ae7298cc35aefeb904d085746dd7cc9 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 15:06:31 +0000 Subject: [PATCH 103/264] 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 fb1eab6cba03b6d1883b75a9aa226230a67ef25a Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 13:36:05 +0000 Subject: [PATCH 104/264] 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 735e7c6a59..46d1057eed 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 a5616e59612b667d11ad354cb95f47fa63db791e Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 13:41:35 +0000 Subject: [PATCH 105/264] 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 46d1057eed..daaf25f565 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 294b1d16f5ab6cd9128252c4ec62b75df3cdb69c Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 14:06:45 +0000 Subject: [PATCH 106/264] 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 710d7329b4540182cdac40582477022a4f43332c Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 15:17:57 +0000 Subject: [PATCH 107/264] 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 cb5c66be1075a7b6068862b62c1be7c0c22d6929 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 09:11:21 +0000 Subject: [PATCH 108/264] 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 1ef27e28da2d320e29a205439e67b08b2dd6e8ff Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 10:23:57 +0000 Subject: [PATCH 109/264] 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 f4aa1c59663ca19eb2580a20cb9d1fcfb5114ddb Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 11:47:56 +0000 Subject: [PATCH 110/264] 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 77a56454dc0a6d4baf3b26779103ce808ff2bce7 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 111/264] 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 6bc1d4e03f352e3d2e64b0a119f6f271afa58cd6 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sun, 2 Mar 2025 23:32:04 -0500 Subject: [PATCH 112/264] 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 269ec5776f..c09c3eac18 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 948aaa8c55f3c3ea5e9a3d0cc8e44dc64063cbb0 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Mon, 3 Mar 2025 20:45:59 -0500 Subject: [PATCH 113/264] 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 c09c3eac18..bcbe193cfd 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 5aae63f32be395a55aa2d2733f07732329b86dee Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 4 Mar 2025 18:43:30 -0500 Subject: [PATCH 114/264] 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 bcbe193cfd..269ec5776f 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 daaf25f565..d33c027273 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 a988d1aaf900cc9796e90db221b2ab9864130653 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 4 Mar 2025 18:46:14 -0500 Subject: [PATCH 115/264] 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 acfcd66b846412895d969081248f253282cadf92 Mon Sep 17 00:00:00 2001 From: Zhen Kong Date: Thu, 13 Mar 2025 17:07:03 +0000 Subject: [PATCH 116/264] 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 19b40d385e744c71124399d45a58a27083d22810 Mon Sep 17 00:00:00 2001 From: James Ring Date: Sun, 16 Mar 2025 23:22:46 -0700 Subject: [PATCH 117/264] 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 7c90432452ea39631efc9b5af1c6c08bb723daec Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Thu, 20 Mar 2025 06:23:20 +0000 Subject: [PATCH 118/264] 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 7abb1eaae87b02d65eecfaa231fec8856290f7cd Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Thu, 20 Mar 2025 07:24:30 +0100 Subject: [PATCH 119/264] 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 da7963ead479a6499b8c5c9a2b54c211e62bab50 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 20 Mar 2025 14:25:13 +0800 Subject: [PATCH 120/264] 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 b411c008be893a45d62ab2c5f3146f605b3e7472 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 121/264] 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 411b0ecd03922cd5e3f6156f0f8fb5170e7bc2fb Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 24 Mar 2025 07:09:22 +0800 Subject: [PATCH 122/264] =?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 fd60fd91ccc9410a737a9b4ef78fb1007cc84b74 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 24 Mar 2025 07:09:57 +0800 Subject: [PATCH 123/264] 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 ff5b90d3757d18dd72d2a6273aae61a556bfba81 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 124/264] 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 683f16f2168a98630dbcf54ef537df9f15e3bd5a 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 125/264] 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 c3397189dcfbcd862ab030e4f78c578cb9653726 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 25 Mar 2025 10:38:34 +0800 Subject: [PATCH 126/264] 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 ef3b80aaa66a0f41f9891a4471d95f15625a48d9 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 27 Mar 2025 14:56:02 +0800 Subject: [PATCH 127/264] 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 edaca83e579d7324806867075f00998f5781647a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 27 Mar 2025 15:01:54 +0800 Subject: [PATCH 128/264] 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 f7d8c0f57ce05d5d9a08c9b9e90ac773aeb8c16a 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 129/264] 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 0799e34d9797c89c292cef1afad4d5b7ad4eda60 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 130/264] 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 a065826a047bcf0d44b2c5e6484614b64f398b08 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 2 Apr 2025 07:13:53 +0800 Subject: [PATCH 131/264] 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 f44980b63c..2de2b7688d 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 63f0d0b4e6591a7ffb22a094285d50933479c490 Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 1 Apr 2025 21:30:45 -0700 Subject: [PATCH 132/264] 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 65e321b45902d8bed52427d364a3784cbfd8cb6b 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 133/264] 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 a87c68027239a390ea7ecf492b0c225af6fe56ef Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 9 Apr 2025 10:26:53 +0800 Subject: [PATCH 134/264] 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 9bde799eb5166d7de2798105c280b631def7070d 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 135/264] 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 e7048796869efc453b269dc8008d005a50b4b99f Mon Sep 17 00:00:00 2001 From: Raul Hernandez Date: Wed, 9 Apr 2025 09:19:48 +0200 Subject: [PATCH 136/264] 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 aa5e473c524867822cbec1eb51d345931359321f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 11:59:59 +0800 Subject: [PATCH 137/264] 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 b72553104b5b0dea73609a4ba93aff2f6f8288b1 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 138/264] 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 fcf629f34d03db700a9ceac44a2e670cadea04b0 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 12:04:56 +0800 Subject: [PATCH 139/264] 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 efc6b122b5891c9f6c824e98d29378767183f433 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 12:06:06 +0800 Subject: [PATCH 140/264] 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 0b78af3390faeac266a4fca36b152161bbbae603 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 14:36:20 +0800 Subject: [PATCH 141/264] 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 593e8c747ad2942e3facd33e6f29d93aa3f81290 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 15 Apr 2025 09:47:18 +0800 Subject: [PATCH 142/264] 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 a1960db45bb82847c820004b5b5b6009689f1b08 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 143/264] 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 8c3a9aa1ea2b86bab6b6bf5b7eaaafb35de7a002 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 15 Apr 2025 12:48:48 +0900 Subject: [PATCH 144/264] 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 bf8022363804196dca94549db05c0e2a00bcf8ac Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 15 Apr 2025 12:51:19 +0800 Subject: [PATCH 145/264] 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 9bdcfe05bf0f48f1f42df1f663d79a3303d36318 Mon Sep 17 00:00:00 2001 From: a seven Date: Thu, 17 Apr 2025 00:04:27 +0800 Subject: [PATCH 146/264] 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 790b74d28da694a988a30aa59815652d673f4c91 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 17 Apr 2025 01:07:08 +0900 Subject: [PATCH 147/264] 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 1b85eed50a6f9b9540f35f5d1fc052c4c0630bf2 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 00:07:25 +0800 Subject: [PATCH 148/264] 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 c1db57449d177bb0f7412652b252712324a10998 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:07:46 +0800 Subject: [PATCH 149/264] 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 95b82b95f56bf294e7e79796e7d43e42e4132a24 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:21:02 +0800 Subject: [PATCH 150/264] 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 6f6654fa1dabd7bd9687cd1c77d089d51ab512a9 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:22:23 +0800 Subject: [PATCH 151/264] 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 c193803a13f7a7a42f4058681bffe5ab6d7780d9 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 16:41:47 +0800 Subject: [PATCH 152/264] 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 d3fa9e7fcbae9f62cc2dcffc782e11980ae1ea2e 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 153/264] 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 bb5d78c5bd..6250585c04 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 @@ -3031,9 +3031,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 @@ -3045,9 +3045,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 963af4b32720edefde3454dff6115d6c3bc7b29c Mon Sep 17 00:00:00 2001 From: James Marsh Date: Wed, 16 Apr 2025 17:34:52 +0100 Subject: [PATCH 154/264] 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 f02f3f2f0e..f33ad60e3b 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 f506e77fa204c23a27d7506976ea34c6c1023fda 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 155/264] 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 156/264] 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 2f213ba0c0b7d8b761258c560051fe3a6784fb76 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 27 Apr 2025 12:30:35 +0900 Subject: [PATCH 157/264] 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 1fb7dee62db8bb21ed2814e5ac908f1bfa1c5366 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 27 Apr 2025 12:48:57 +0900 Subject: [PATCH 158/264] 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 fc6c9a3bb0b791cc5ea3c91d084467166bf2a3c6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 28 Apr 2025 17:43:53 +0900 Subject: [PATCH 159/264] 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 5c093a89b526518f660d74d01417165ef09b4e0e Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 28 Apr 2025 21:44:04 +0800 Subject: [PATCH 160/264] 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 70ed8b888738f3687691db41f07836fb81c9d025 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 29 Apr 2025 10:05:02 +0800 Subject: [PATCH 161/264] 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 ef34aa50ccfdc4970d52c9bcad1210e60f7a5203 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 29 Apr 2025 11:41:34 +0800 Subject: [PATCH 162/264] 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 cf2f06dda58c86b3388052ca1d98c43b112fd093 Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Wed, 30 Apr 2025 14:10:56 +0800 Subject: [PATCH 163/264] 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 58ced77b534282731bc58c43d1c493e7e087a4bd Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 07:55:35 +0900 Subject: [PATCH 164/264] 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 34980224949c1a1fc54cde7eb3f29cedc5b75a76 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 07:55:42 +0900 Subject: [PATCH 165/264] 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 64653ddf8a9a27376bcbc72331b421841e73037b Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 6 May 2025 06:55:53 +0800 Subject: [PATCH 166/264] 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 4e24a361d0c67e6df20c034d1ad9f41e0440aa11 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 6 May 2025 06:56:06 +0800 Subject: [PATCH 167/264] 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 657a8cb7b8a9de5274f40160a4b95f77bc2bc115 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 11:15:00 +0900 Subject: [PATCH 168/264] 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 4544339ce13d10941d28af224abdec2d42a380fd 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 169/264] 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 0024b5748d7052f75d144f87b4e100bcbae18fda Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 08:09:44 +0900 Subject: [PATCH 170/264] 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 13c1c1020d7bc32eb52edc6f1c97a264ab96ce0b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 10:42:51 +0900 Subject: [PATCH 171/264] 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 5cb9b973bd1b0e183b7dd4f803629a3d19136f0b Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 7 May 2025 09:45:49 +0800 Subject: [PATCH 172/264] 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 eb06490c6567138855c85f93d38c61445cd1030c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 12:32:14 +0900 Subject: [PATCH 173/264] 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 9b117fb55a8b3cac86a92a2fad2fca3b102612a5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 12:32:29 +0900 Subject: [PATCH 174/264] 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 6bde4503f683155e38b61ef7a5b86477f66f158e 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 175/264] 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 6a48b3fec44eef5f1e1a411372e637b1952307eb Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 8 May 2025 08:47:07 +0800 Subject: [PATCH 176/264] 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 | 8 +++++++- core/shared/platform/zephyr/zephyr_platform.c | 6 ++++++ 11 files changed, 72 insertions(+), 3 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 75e5f0e2b1..3a66bba9f1 100644 --- a/core/shared/platform/common/posix/posix_file.c +++ b/core/shared/platform/common/posix/posix_file.c @@ -1060,4 +1060,10 @@ bool os_compare_file_handle(os_file_handle handle1, os_file_handle handle2) { return handle1 == handle2; -} \ 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 754ae81f24..a44b57e25c 100644 --- a/core/shared/platform/esp-idf/espidf_file.c +++ b/core/shared/platform/esp-idf/espidf_file.c @@ -1044,4 +1044,10 @@ int os_poll(os_poll_file_handle *fds, os_nfds_t nfs, int timeout) { return BHT_ERROR; -} \ 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 6d9cbaef6b..41ec5742bc 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 6fca9237cd..ef7896cc2d 100644 --- a/core/shared/platform/windows/win_file.c +++ b/core/shared/platform/windows/win_file.c @@ -1845,4 +1845,10 @@ int os_poll(os_poll_file_handle *fds, os_nfds_t nfs, int timeout) { return BHT_ERROR; -} \ No newline at end of file +} + +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 acf97ce73d89697a91d73691195655588d438b7c 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 177/264] 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 0f415011882faf0727a3836490166c38bd9e3bfe Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 May 2025 11:24:55 +0900 Subject: [PATCH 178/264] 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 b9287b8e372a73c48af7af4dcbefe6f73e7a684f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 May 2025 11:34:04 +0900 Subject: [PATCH 179/264] 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 708baaa40a1021102a83ce61ecf6a5f44ab83bb7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 10:29:06 +0900 Subject: [PATCH 180/264] 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 320354435d337f9b5a8dbd43cb55d29f3e56ae44 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 9 May 2025 14:01:29 +0800 Subject: [PATCH 181/264] 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 6250585c04..df6817504d 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 @@ -1226,43 +1226,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 d1fddf5e49b09d89c42d3fb5237ce581b189ad70 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 18:14:02 +0900 Subject: [PATCH 182/264] 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 bfc9e99843109ea14cdf09b2e9da046aa0ff5310 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 9 May 2025 17:14:20 +0800 Subject: [PATCH 183/264] 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 4c4e2ae11e06d919213411b34dc681ee4899a7c4 Mon Sep 17 00:00:00 2001 From: James Ring Date: Fri, 9 May 2025 02:14:33 -0700 Subject: [PATCH 184/264] 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 246582e22465bd6e4604ee5c5d04d260bd1cd39e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 18:38:48 +0900 Subject: [PATCH 185/264] 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 c4954e26409df42122508dcec3abbccc6dc0a415 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 186/264] 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 77b43398b9b7912341c252f9683121f76ec59192 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 187/264] 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 80d0b0614fadb32e856b5490b4b79a1338c322cb Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 13 May 2025 13:40:24 +0900 Subject: [PATCH 188/264] 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 3b12d53f8f2e3bc062ad475551c2b376fa261721 Mon Sep 17 00:00:00 2001 From: Su Yihan Date: Wed, 14 May 2025 06:35:32 +0800 Subject: [PATCH 189/264] 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 c9327e507956b8da73350de2dc3c453d15175236 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:38:30 +0800 Subject: [PATCH 190/264] 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 5a3be9b7830f5dfb3b57d97f9c52007041086dd4 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:38:49 +0800 Subject: [PATCH 191/264] 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 3e03883d5218f2e686d71bc18d5451622d41eb92 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:39:06 +0800 Subject: [PATCH 192/264] 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 720563977d22f98a5ab9c0b46553ad50de46d978 Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 13 May 2025 19:58:19 -0700 Subject: [PATCH 193/264] 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 92963de8519f7a5def6808c7251fa2b487533b21 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 11:09:08 +0800 Subject: [PATCH 194/264] 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 59a63813563a83be75fefef87792f150d55e8f4d Mon Sep 17 00:00:00 2001 From: Maks Litskevich Date: Wed, 14 May 2025 05:35:56 +0100 Subject: [PATCH 195/264] 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 847dcf78016583a1190e06e998f34eaee211c00c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 12:43:55 +0800 Subject: [PATCH 196/264] 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 178eeb8a9adac04b9a2aa4af970ea752157b06b9 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 197/264] 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 910dd9815b2203a902164732e01295334f5d403a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 19 May 2025 10:31:17 +0800 Subject: [PATCH 198/264] 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 0114b6b172904fbcecbc245bc9d7c34ef96211b0 Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Mon, 19 May 2025 10:32:07 +0800 Subject: [PATCH 199/264] 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 e11f3feb307da0619732e629be2310ad83247a1a 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 200/264] 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 489d745190487980861c5ba8b57775d643003948 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 201/264] 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 bb0397b4e01822e1be22de8255df949fbb861d1f 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 202/264] 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 7c71a679f23a9e900f895ceab28a2d4f32e03ff6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 23 May 2025 17:56:21 +0900 Subject: [PATCH 203/264] 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 3890642b0f380fa8448324c7f078ed6ea9471f85 Mon Sep 17 00:00:00 2001 From: Alix ANNERAUD Date: Mon, 26 May 2025 10:16:42 +0200 Subject: [PATCH 204/264] 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 8a2b39793937da80f6be02624c21e5d4afa9a0ef Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 09:05:07 +0800 Subject: [PATCH 205/264] 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 967d3f26a3cc05229815b12c97f1d72be3327323 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 28 May 2025 10:05:29 +0900 Subject: [PATCH 206/264] 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 3f7df5cc00dc7f49aa8158ec58ee48570b2d464e Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 20:29:09 +0800 Subject: [PATCH 207/264] 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 36d9bdf3d1ad8755830227dd4b6e698f0ed49877 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 208/264] 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 9be60028f698fe821535a34f650e792bc88260f1 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 20:30:05 +0800 Subject: [PATCH 209/264] 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 92dd7f233c14d7d5ac1456911918c33bebbb9dcf Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 30 May 2025 07:42:39 +0800 Subject: [PATCH 210/264] 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 cdef0b0cd0837368d4395caf918a4e7da5c7b75a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 2 Jun 2025 10:45:50 +0800 Subject: [PATCH 211/264] 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 a86a2fc5666b5dcfe8177ab8b1b24e9b7a47d2b6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 2 Jun 2025 16:30:51 +0800 Subject: [PATCH 212/264] 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 b2c47e2fffa7150355bbb51e56ddfd3af9577513 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 213/264] 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 e0f891bd7815ff30e59aeda6a3a2005ae171508d 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 214/264] 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 a3c29bca6eca1f15739364bc2ee4c5ff4df0cfe1 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 3 Jun 2025 13:21:17 +0800 Subject: [PATCH 215/264] 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 a66992862cc50662e4924eb9bb14133cf9f84c1a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:21:32 +0900 Subject: [PATCH 216/264] 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 e3240fd719b07388162dc7c64edeab699cea55e4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:22:27 +0900 Subject: [PATCH 217/264] 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 5f4467a623c2e80a0b9f083c5db97f618386c403 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:22:48 +0900 Subject: [PATCH 218/264] 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 84ab7b0f9dbef911add2d730bec249cb85ef1e17 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:23:19 +0900 Subject: [PATCH 219/264] 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 b9affecd0ff1d6a7e66fccecdb9112d22586841d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:28:13 +0900 Subject: [PATCH 220/264] 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 15aa085d647b7359f74df84259376ff9a2b4e3a1 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 221/264] 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 ff14d9aed3f0e3677179f5191ddc6b7525f148e4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:19:46 +0900 Subject: [PATCH 222/264] 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 fc8456fd00a8896baa8bed85aef76f942b1ea6ac Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:48:00 +0900 Subject: [PATCH 223/264] 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 1fdb20af69a0e73ed8f598bdd3ae51ad01c48762 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:48:28 +0900 Subject: [PATCH 224/264] 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 369827847f15723120d6878b1649602e858e995d Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 5 Jun 2025 11:57:29 +0800 Subject: [PATCH 225/264] 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 586ecd4a63cf8b3800426c3b8fdf54577a252edd Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 6 Jun 2025 15:05:04 +0800 Subject: [PATCH 226/264] 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 32705ee29fd1bf0f6b366988b7e566c10a28bdb2 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 6 Jun 2025 15:05:44 +0800 Subject: [PATCH 227/264] 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 286ae4140d495fa183ca8432a3803f08453bf66e 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 228/264] 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 fd30c958831d41412c40daf9b0146295b67ad125 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 6 Jun 2025 16:07:29 +0900 Subject: [PATCH 229/264] 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 fa023f7883c1133f4e94ff5b8602b0ae86de8953 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 6 Jun 2025 16:08:18 +0900 Subject: [PATCH 230/264] 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 7aba6bbd22d4b6158d426c657d8f7ac2e89462a6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 9 Jun 2025 11:35:24 +0800 Subject: [PATCH 231/264] 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 1c55af8175fee97881bba898a61fd9d661af9301 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 9 Jun 2025 12:36:05 +0900 Subject: [PATCH 232/264] 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 aac70b352e3eaec9b373a1949210bae890ed20fc Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 9 Jun 2025 12:36:31 +0900 Subject: [PATCH 233/264] 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 5016209bb8a71b172fe2ab074e349d18bbedc358 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 234/264] 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 a466359ee64f97b77720b53bda549b3f4e8e67a4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 11 Jun 2025 08:46:35 +0900 Subject: [PATCH 235/264] 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 234e9399f769defda13f304cbfd4940bf70c418b 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 236/264] 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 871c58f5dbeba8336308f7a4e672146843ab2e90 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 237/264] 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 afb6e31eda81d6a96eb118c1bc84ef558c06316a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:29:59 +0900 Subject: [PATCH 238/264] 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 725fe39a685d2a6b860560caa437993082189816 Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Thu, 12 Jun 2025 09:31:17 +0800 Subject: [PATCH 239/264] 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 24ccf68e3a0b25353606fa02554e96ab52e18680 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:33:25 +0900 Subject: [PATCH 240/264] 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 fae2def7249e6cfe251ffc7a4356632e8641e4b6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 12 Jun 2025 10:34:14 +0900 Subject: [PATCH 241/264] 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 aebc4e544ffca0c01a65f5f7ee6cd44e16095c7f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 15:01:42 +0800 Subject: [PATCH 242/264] 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 6599caa450a632c77a86056620cb25582c35f1da Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:05:52 +0800 Subject: [PATCH 243/264] 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 046a421a9157417283fb28dc587505e3eb01df19 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:06:33 +0800 Subject: [PATCH 244/264] 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 d18664fba23ee6c8c2604833d93d7889a9ead14b Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 12 Jun 2025 16:06:57 +0800 Subject: [PATCH 245/264] 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 5f49db989044536275b0a201485cad64643af7d1 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 246/264] 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 2160d079b5c44100f43129c66d0f8834e5eec9c8 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 247/264] 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 caf826e94650b4a2e2b65c7368918dcaa3ee6660 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:01:07 +0900 Subject: [PATCH 248/264] 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 98d3f6f6381271eb2e8439de038fe8782d69f268 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 249/264] 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 7fe7bd9ff868af288a6428572f9cd57af3c6c7a0 Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Tue, 17 Jun 2025 11:01:38 +0800 Subject: [PATCH 250/264] 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 90f9902881d0fcad893463dc7c122171e1696713 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:02:36 +0900 Subject: [PATCH 251/264] 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 75c60321c0fe70bb753fa5f6fa871878d27f84b2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:13:43 +0900 Subject: [PATCH 252/264] 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 2c9554e8817b0169cb4f4d84059010dbf0875760 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 17 Jun 2025 11:14:10 +0800 Subject: [PATCH 253/264] 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 b08052a8e8fd95a48e0e11f6744e0c05ea35b451 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:15:01 +0900 Subject: [PATCH 254/264] 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 26bde920c2764fc86d09655f63b21dca7f8e2431 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 12:17:00 +0900 Subject: [PATCH 255/264] 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 d5a7f018dc357eec7bdfbd7f853eb09ae056568f Mon Sep 17 00:00:00 2001 From: Su Yihan Date: Tue, 17 Jun 2025 13:00:58 +0800 Subject: [PATCH 256/264] 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 f2e5fa8f7c18be3f6b08f60eea23c4d3dac2dc2c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 14:01:46 +0900 Subject: [PATCH 257/264] 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 751e7cf7fc49946743816c8d88251e7a9aba8931 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:39:34 +0900 Subject: [PATCH 258/264] 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 cab32afe816d66f55724a4c4f4bed6ff2bb491e1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:40:23 +0900 Subject: [PATCH 259/264] 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 fa949e396240f5e5d14059473fc288ef60341a4e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Jun 2025 18:40:53 +0900 Subject: [PATCH 260/264] 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 7d5c9c2b300420924c351b9d8dd1108857f8d21d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:06:57 +0900 Subject: [PATCH 261/264] 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 c4110d3441f584c1f65aa42ffb411f223991a220 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:08:57 +0900 Subject: [PATCH 262/264] 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 9d28a44de14d4e7d3ba773ef0c25b6207629f826 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 18 Jun 2025 19:16:47 +0800 Subject: [PATCH 263/264] 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 64ef3695c31e6a5365a3b62e612f4e9d71fbc7c0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Jun 2025 20:24:06 +0900 Subject: [PATCH 264/264] 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