Kaynağa Gözat

Merge remote-tracking branch 'upstream/main' into fix/merge_into_dev_shared_heap_from_main

From 68e4534822d1f1ccf353831e64853e221fd0bd77 Iterate callstack API
to 7f968f59260c1a5198b07e3a2f56106e33902836 wasi_socket_ext.c: avoid tls to make this library-friendly
liang.he@intel.com 8 ay önce
ebeveyn
işleme
c7473d5976
100 değiştirilmiş dosya ile 4935 ekleme ve 1437 silme
  1. 7 11
      .dockerignore
  2. 47 0
      .github/actions/install-linux-sgx/action.yml
  3. 80 0
      .github/actions/install-wasi-sdk-wabt/action.yml
  4. 2 1
      .github/workflows/build_iwasm_release.yml
  5. 1 8
      .github/workflows/build_llvm_libraries.yml
  6. 7 0
      .github/workflows/build_wamr_lldb.yml
  7. 2 1
      .github/workflows/build_wamrc.yml
  8. 29 0
      .github/workflows/check_version_h.yml
  9. 4 4
      .github/workflows/codeql.yml
  10. 1 1
      .github/workflows/coding_guidelines.yml
  11. 47 83
      .github/workflows/compilation_on_android_ubuntu.yml
  12. 64 47
      .github/workflows/compilation_on_macos.yml
  13. 2 2
      .github/workflows/compilation_on_nuttx.yml
  14. 82 102
      .github/workflows/compilation_on_sgx.yml
  15. 62 20
      .github/workflows/compilation_on_windows.yml
  16. 50 122
      .github/workflows/nightly_run.yml
  17. 24 79
      .github/workflows/release_process.yml
  18. 3 25
      .github/workflows/spec_test_on_nuttx.yml
  19. 3 3
      .github/workflows/supply_chain.yml
  20. 37 53
      CMakeLists.txt
  21. 1 1
      CONTRIBUTING.md
  22. 1 1
      README.md
  23. 493 230
      RELEASE_NOTES.md
  24. 7 13
      build-scripts/build_llvm.py
  25. 148 51
      build-scripts/config_common.cmake
  26. 1 1
      build-scripts/esp-idf/README.md
  27. 19 11
      build-scripts/esp-idf/wamr/CMakeLists.txt
  28. 6 0
      build-scripts/iwasmConfig.cmake.in
  29. 30 0
      build-scripts/package.cmake
  30. 20 1
      build-scripts/runtime_lib.cmake
  31. 28 0
      build-scripts/version.cmake
  32. 20 11
      ci/coding_guidelines_check.py
  33. 18 0
      core/config.h
  34. 46 6
      core/iwasm/aot/aot_intrinsic.c
  35. 19 3
      core/iwasm/aot/aot_intrinsic.h
  36. 35 9
      core/iwasm/aot/aot_loader.c
  37. 29 19
      core/iwasm/aot/aot_perf_map.c
  38. 4 0
      core/iwasm/aot/aot_reloc.h
  39. 173 9
      core/iwasm/aot/aot_runtime.c
  40. 7 0
      core/iwasm/aot/aot_runtime.h
  41. 45 0
      core/iwasm/aot/aot_validator.c
  42. 15 0
      core/iwasm/aot/aot_validator.h
  43. 1 1
      core/iwasm/aot/arch/aot_reloc_aarch64.c
  44. 39 0
      core/iwasm/aot/arch/aot_reloc_dummy.c
  45. 19 12
      core/iwasm/aot/arch/aot_reloc_x86_32.c
  46. 1 1
      core/iwasm/aot/arch/aot_reloc_xtensa.c
  47. 24 2
      core/iwasm/aot/iwasm_aot.cmake
  48. 2 2
      core/iwasm/common/arch/invokeNative_aarch64.s
  49. 2 2
      core/iwasm/common/arch/invokeNative_aarch64_simd.s
  50. 1 1
      core/iwasm/common/arch/invokeNative_arm_vfp.s
  51. 3 3
      core/iwasm/common/arch/invokeNative_riscv.S
  52. 1 1
      core/iwasm/common/arch/invokeNative_thumb_vfp.s
  53. 13 9
      core/iwasm/common/gc/gc_type.c
  54. 1 1
      core/iwasm/common/wasm_application.c
  55. 1 1
      core/iwasm/common/wasm_c_api.c
  56. 8 4
      core/iwasm/common/wasm_exec_env.c
  57. 5 0
      core/iwasm/common/wasm_exec_env.h
  58. 6 4
      core/iwasm/common/wasm_loader_common.c
  59. 14 6
      core/iwasm/common/wasm_memory.c
  60. 65 9
      core/iwasm/common/wasm_runtime_common.c
  61. 135 14
      core/iwasm/common/wasm_runtime_common.h
  62. 7 0
      core/iwasm/compilation/aot_compiler.c
  63. 1 1
      core/iwasm/compilation/aot_compiler.h
  64. 64 26
      core/iwasm/compilation/aot_emit_aot_file.c
  65. 22 0
      core/iwasm/compilation/aot_emit_control.c
  66. 48 44
      core/iwasm/compilation/aot_emit_conversion.c
  67. 3 3
      core/iwasm/compilation/aot_emit_memory.c
  68. 44 20
      core/iwasm/compilation/aot_emit_numberic.c
  69. 36 11
      core/iwasm/compilation/aot_llvm.c
  70. 3 0
      core/iwasm/compilation/aot_llvm.h
  71. 6 1
      core/iwasm/compilation/aot_llvm_extra.cpp
  72. 11 0
      core/iwasm/compilation/aot_llvm_extra2.cpp
  73. 4 0
      core/iwasm/compilation/debug/dwarf_extractor.cpp
  74. 1 1
      core/iwasm/compilation/iwasm_compl.cmake
  75. 1 1
      core/iwasm/compilation/simd/simd_int_arith.c
  76. 10 10
      core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp
  77. 1 1
      core/iwasm/fast-jit/fe/jit_emit_compare.c
  78. 1 1
      core/iwasm/fast-jit/fe/jit_emit_control.c
  79. 7 1
      core/iwasm/fast-jit/iwasm_fast_jit.cmake
  80. 2 2
      core/iwasm/fast-jit/jit_frontend.c
  81. 5 5
      core/iwasm/fast-jit/jit_ir.h
  82. 4 4
      core/iwasm/fast-jit/jit_regalloc.c
  83. 9 0
      core/iwasm/include/aot_comp_option.h
  84. 1 1
      core/iwasm/include/wasm_c_api.h
  85. 59 1
      core/iwasm/include/wasm_export.h
  86. 1 1
      core/iwasm/interpreter/wasm.h
  87. 51 26
      core/iwasm/interpreter/wasm_interp_classic.c
  88. 1848 134
      core/iwasm/interpreter/wasm_interp_fast.c
  89. 423 92
      core/iwasm/interpreter/wasm_loader.c
  90. 37 3
      core/iwasm/interpreter/wasm_mini_loader.c
  91. 24 3
      core/iwasm/interpreter/wasm_opcode.h
  92. 56 7
      core/iwasm/interpreter/wasm_runtime.c
  93. 8 0
      core/iwasm/interpreter/wasm_runtime.h
  94. 3 3
      core/iwasm/libraries/debug-engine/debug_engine.c
  95. 1 1
      core/iwasm/libraries/debug-engine/debug_engine.h
  96. 1 1
      core/iwasm/libraries/debug-engine/gdbserver.c
  97. 1 1
      core/iwasm/libraries/debug-engine/gdbserver.h
  98. 62 28
      core/iwasm/libraries/debug-engine/handler.c
  99. 2 2
      core/iwasm/libraries/debug-engine/handler.h
  100. 7 0
      core/iwasm/libraries/lib-rats/lib_rats.cmake

+ 7 - 11
.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

+ 47 - 0
.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

+ 80 - 0
.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

+ 2 - 1
.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
 

+ 1 - 8
.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
@@ -88,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

+ 7 - 0
.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 \

+ 2 - 1
.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
 

+ 29 - 0
.github/workflows/check_version_h.yml

@@ -0,0 +1,29 @@
+# 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
+
+    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

+ 4 - 4
.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.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.8
+      uses: github/codeql-action/analyze@v3.28.19
       with:
         category: "/language:${{matrix.language}}"
         upload: false
@@ -99,14 +99,14 @@ 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.19
       with:
         sarif_file: ${{ steps.step1.outputs.sarif-output }}
         category: "/language:${{matrix.language}}"
 
     - name: Upload CodeQL results as an artifact
       if: success() || failure()
-      uses: actions/upload-artifact@v4.6.0
+      uses: actions/upload-artifact@v4.6.2
       with:
         name: codeql-results
         path: ${{ steps.step1.outputs.sarif-output }}

+ 1 - 1
.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

+ 47 - 83
.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
@@ -152,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",
@@ -172,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"
@@ -310,17 +315,14 @@ jobs:
       fail-fast: false
       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",
-          ]
+        build_target: [
+          "X86_64",
+          "X86_32",
+        ]
         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
@@ -341,19 +343,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-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 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: |
@@ -362,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
@@ -392,14 +391,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 }}
@@ -425,12 +416,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'))
@@ -448,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:
       [
@@ -459,34 +453,14 @@ 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_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-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: Get LLVM libraries
         id: retrieve_llvm_libs
         uses: actions/cache@v4
@@ -498,12 +472,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
@@ -629,10 +610,6 @@ jobs:
             $MEMORY64_TEST_OPTIONS,
             $MULTI_MEMORY_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_2204.outputs.cache_key }}
@@ -643,11 +620,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
@@ -675,7 +650,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"
@@ -703,20 +678,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 mv wasi-sdk-20.0 wasi-sdk
-
-      # 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
+        uses: ./.github/actions/install-wasi-sdk-wabt
+        with:
+          os: ${{ matrix.os }}
 
       - name: set env variable(if llvm are used)
         if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
@@ -754,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

+ 64 - 47
.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,60 +217,82 @@ 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]
-        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 }}
+
     steps:
       - name: checkout
         uses: actions/checkout@v4
 
-      - name: download and install wabt
+      - 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: |
-          cd /opt
-          sudo wget ${{ matrix.wabt_release }}
-          sudo tar -xzf wabt-1.0.31-*.tar.gz
-          sudo mv wabt-1.0.31 wabt
+          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
 
+      - 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 }}
     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 +302,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 +372,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

+ 2 - 2
.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

+ 82 - 102
.github/workflows/compilation_on_sgx.yml

@@ -49,10 +49,14 @@ 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"
+  # 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:
@@ -97,12 +101,12 @@ 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",
           ]
-        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,69 +146,29 @@ jobs:
             #$LLVM_LAZY_JIT_BUILD_OPTIONS,
             #$LLVM_EAGER_JIT_BUILD_OPTIONS,
           ]
-        os: [ubuntu-20.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",
-          ]
+        os: [ubuntu-22.04]
         iwasm_make_options_feature: [
             # Features to be tested: IPFS
             "-DWAMR_BUILD_SGX_IPFS=1",
           ]
         platform: [linux-sgx]
         include:
-          - os: ubuntu-20.04
+          - os: ubuntu-22.04
             llvm_cache_key: ${{ needs.build_llvm_libraries.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 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: 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-wasi-sdk-wabt
+        uses: ./.github/actions/install-wasi-sdk-wabt
+        with:
+          os: ${{ matrix.os }}
 
       - 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: |
@@ -240,59 +196,61 @@ 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:
     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,22 +274,44 @@ 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: |
+          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

+ 62 - 20
.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,

+ 50 - 122
.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,18 +377,10 @@ jobs:
             $LLVM_EAGER_JIT_BUILD_OPTIONS,
             $MULTI_TIER_JIT_BUILD_OPTIONS,
           ]
-        os: [ubuntu-20.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",
-          ]
+        os: [ubuntu-22.04]
         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
@@ -432,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: |
@@ -457,44 +429,23 @@ 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]
-        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",
-          ]
+        os: [ubuntu-22.04]
         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
 
-      - 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
@@ -591,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,18 +568,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:
           [
@@ -643,22 +592,12 @@ 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-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
@@ -700,22 +639,11 @@ 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
-
-      # It is a temporary solution until new wasi-sdk that includes bug fixes is released
-      - name: build wasi-libc from source
+      - name: install-wasi-sdk-wabt
         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
+        uses: ./.github/actions/install-wasi-sdk-wabt
+        with:
+          os: ${{ matrix.os }}
 
       - name: set env variable(if llvm are used)
         if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
@@ -761,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

+ 24 - 79
.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
@@ -135,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
@@ -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
@@ -239,41 +192,33 @@ 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
-  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

+ 3 - 25
.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
@@ -351,7 +329,7 @@ jobs:
 
       - name: upload the log
         if: always()
-        uses: actions/upload-artifact@v4.6.0
+        uses: actions/upload-artifact@v4.6.2
         with:
           name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
           path: log

+ 3 - 3
.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@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
         with:
           results_file: results.sarif
           results_format: sarif
@@ -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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0
         with:
           name: SARIF file
           path: results.sarif
@@ -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@b1e4dc3db58c9601794e22a9f6d28d45461b9dbf 
         with:
           sarif_file: results.sarif

+ 37 - 53
CMakeLists.txt

@@ -1,7 +1,9 @@
 # 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)
 
 if(ESP_PLATFORM)
   include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt)
@@ -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 "")
@@ -104,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)
@@ -152,56 +152,40 @@ 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 ()
-
-# 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 ()
+add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
+set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm)
+target_include_directories(vmlib INTERFACE
+  $<BUILD_INTERFACE:${WAMR_ROOT_DIR}/core/iwasm/include>
+  $<INSTALL_INTERFACE:include>
+)
 
-    if (WIN32)
-      target_link_libraries(iwasm_static PRIVATE ntdll)
-    endif()
+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 ()
 
-    install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
+if (MINGW)
+  target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32)
+  target_link_libraries(vmlib PRIVATE ws2_32)
 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 (WIN32)
+  target_link_libraries(vmlib PRIVATE ntdll)
+endif()
 
-    if (MINGW)
-      target_link_libraries(iwasm_shared INTERFACE -lWs2_32 -lwsock32)
-      target_link_libraries(iwasm_shared PRIVATE ws2_32)
-    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}")
 
-    if (WIN32)
-      target_link_libraries(iwasm_shared PRIVATE ntdll)
-    endif()
+set_version_info (vmlib)
 
-    install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
-endif ()
+install (TARGETS vmlib
+  EXPORT iwasmTargets
+  LIBRARY DESTINATION lib
+  PUBLIC_HEADER DESTINATION include
+)
 
-# 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
-    DESTINATION include)
+install_iwasm_package ()

+ 1 - 1
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.

+ 1 - 1
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

Dosya farkı çok büyük olduğundan ihmal edildi
+ 493 - 230
RELEASE_NOTES.md


+ 7 - 13
build-scripts/build_llvm.py

@@ -112,17 +112,11 @@ 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"]
         )
 
-    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 ""
     ]
@@ -217,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))
@@ -231,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")
@@ -300,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",
         },
     }
 

+ 148 - 51
build-scripts/config_common.cmake

@@ -131,6 +131,12 @@ else ()
   unset (LLVM_AVAILABLE_LIBS)
 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)
@@ -151,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()
@@ -167,16 +176,63 @@ 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 ("     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")
 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,25 +263,55 @@ 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 ()
   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 ()
   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()
+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)
   message ("     Multiple modules enabled")
@@ -233,24 +319,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)
@@ -263,6 +335,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.*")
@@ -270,31 +350,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")
@@ -322,12 +382,14 @@ 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)
-    message ("     SIMD enabled")
-  else ()
+  if (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)
@@ -354,16 +416,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 +432,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 ()
@@ -610,4 +666,45 @@ 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 ()
+if (WAMR_BUILD_INSTRUCTION_METERING EQUAL 1)
+  message ("     Instruction metering enabled")
+  add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1)
 endif ()
+
+########################################
+# Show Phase4 Wasm proposals status.
+########################################
+
+message (
+"-- About Wasm Proposals:\n"
+"     Always-on:\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"
+"       \"Extended Constant Expressions\"\n"
+"       \"Import/Export of Mutable Globals\"\n"
+"       \"JS String Builtins\"\n"
+"       \"Relaxed SIMD\"\n"
+)

+ 1 - 1
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)
 

+ 19 - 11
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 ()

+ 6 - 0
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")

+ 30 - 0
build-scripts/package.cmake

@@ -0,0 +1,30 @@
+# 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
+        NAMESPACE iwasm::
+        DESTINATION lib/cmake/iwasm
+    )
+
+    include (CMakePackageConfigHelpers)
+    configure_package_config_file (${_WAMR_BUILD_SCRIPTS_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()

+ 20 - 1
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 ()
@@ -168,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
@@ -181,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)

+ 28 - 0
build-scripts/version.cmake

@@ -0,0 +1,28 @@
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+if(NOT WAMR_ROOT_DIR)
+  # if from wamr-compiler
+  set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
+endif()
+
+set(WAMR_VERSION_MAJOR 2)
+set(WAMR_VERSION_MINOR 3)
+set(WAMR_VERSION_PATCH 1)
+
+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()

+ 20 - 11
ci/coding_guidelines_check.py

@@ -13,8 +13,8 @@ import subprocess
 import sys
 import unittest
 
-CLANG_FORMAT_CMD = "clang-format-12"
-GIT_CLANG_FORMAT_CMD = "git-clang-format-12"
+CLANG_FORMAT_CMD = "clang-format-14"
+GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
 
 # glob style patterns
 EXCLUDE_PATHS = [
@@ -32,7 +32,7 @@ EXCLUDE_PATHS = [
     "**/tests/wamr-test-suites/workspace/*",
 ]
 
-C_SUFFIXES = [".c", ".cpp", ".h"]
+C_SUFFIXES = [".c", ".cc", ".cpp", ".h"]
 INVALID_DIR_NAME_SEGMENT = r"([a-zA-Z0-9]+\_[a-zA-Z0-9]+)"
 INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
 
@@ -93,20 +93,29 @@ 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
-    and install it
+    1. Install clang-format-14.0.0
+
+    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
     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 */`
@@ -145,7 +154,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

+ 18 - 0
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
@@ -318,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
@@ -702,4 +712,12 @@
 #define WASM_ENABLE_SHRUNK_MEMORY 1
 #endif
 
+#ifndef WASM_ENABLE_AOT_VALIDATOR
+#define WASM_ENABLE_AOT_VALIDATOR 0
+#endif
+
+#ifndef WASM_ENABLE_INSTRUCTION_METERING
+#define WASM_ENABLE_INSTRUCTION_METERING 0
+#endif
+
 #endif /* end of _CONFIG_H_ */

+ 46 - 6
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;
@@ -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
@@ -866,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)) {
         /*
@@ -878,9 +921,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 {
         /*

+ 19 - 3
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 */
 
@@ -182,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
@@ -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);

+ 35 - 9
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"
@@ -314,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
@@ -584,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 */
@@ -1106,9 +1113,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;
@@ -1251,6 +1255,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) {
@@ -1710,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 */
@@ -3184,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)
@@ -4120,6 +4127,18 @@ 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();
+#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
 fail2:
@@ -4403,6 +4422,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;
 }

+ 29 - 19
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;
@@ -32,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 *
@@ -46,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;
     }
 
@@ -78,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,
@@ -89,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, "%lx  %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",
-                     (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",
@@ -113,8 +124,7 @@ quit:
         wasm_runtime_free(sorted_func_ptrs);
 
     if (perf_map)
-        fclose(perf_map);
+        (void)fclose(perf_map);
 
     return ret;
 }
-#endif /* WASM_ENABLE_LINUX_PERF != 0 */

+ 4 - 0
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),     \

+ 173 - 9
core/iwasm/aot/aot_runtime.c

@@ -2317,13 +2317,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");
@@ -2342,6 +2335,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) {
@@ -2632,7 +2632,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);
@@ -2653,7 +2653,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;
     }
 }
 
@@ -3287,8 +3287,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);
@@ -3329,8 +3346,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;
 
@@ -4105,6 +4139,136 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
 }
 #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
 
+#if WAMR_ENABLE_COPY_CALLSTACK != 0
+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)
+{
+    /*
+     * Note for devs: please refrain from such modifications inside of
+     * 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_copy_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;
+    uint32 count = 0;
+
+    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";
+        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";
+        strncpy(error_buf, err_msg, error_buf_size);
+        return 0;
+    }
+
+    AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
+    WASMCApiFrame record_frame;
+    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;
+        buffer[count - skip_n] = record_frame;
+        frame -= 1;
+        ++count;
+    }
+    return count >= skip_n ? count - skip_n : 0;
+}
+
+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)
+{
+    /*
+     * Note for devs: please refrain from such modifications inside of
+     * 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
+     * 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);
+    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 + 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;
+        buffer[count - skip_n] = record_frame;
+        cur_frame = cur_frame->prev_frame;
+        ++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 >= skip_n ? count - skip_n : 0;
+}
+
+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)
+{
+    /*
+     * 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)) {
+        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);
+    }
+}
+#endif // WAMR_ENABLE_COPY_CALLSTACK
+
 #if WASM_ENABLE_DUMP_CALL_STACK != 0
 bool
 aot_create_call_stack(struct WASMExecEnv *exec_env)

+ 7 - 0
core/iwasm/aot/aot_runtime.h

@@ -776,6 +776,13 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
 bool
 aot_create_call_stack(struct WASMExecEnv *exec_env);
 
+#if WAMR_ENABLE_COPY_CALLSTACK != 0
+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);
+#endif // WAMR_ENABLE_COPY_CALLSTACK
+
 /**
  * @brief Dump wasm call stack or get the size
  *

+ 45 - 0
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;
+}

+ 15 - 0
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_ */

+ 1 - 1
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;

+ 39 - 0
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();
+}

+ 19 - 12
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 */
 

+ 1 - 1
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)

+ 24 - 2
core/iwasm/aot/iwasm_aot.cmake

@@ -1,15 +1,37 @@
 # 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)
 
 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")
+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)

+ 2 - 2
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) */

+ 2 - 2
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) */

+ 1 - 1
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
 

+ 3 - 3
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

+ 1 - 1
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
 

+ 13 - 9
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);

+ 1 - 1
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))) {

+ 1 - 1
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;

+ 8 - 4
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
@@ -202,7 +206,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
@@ -276,8 +280,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 +288,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);

+ 5 - 0
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

+ 6 - 4
core/iwasm/common/wasm_loader_common.c

@@ -151,11 +151,13 @@ 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_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;

+ 14 - 6
core/iwasm/common/wasm_memory.c

@@ -1475,6 +1475,14 @@ 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) {
+        LOG_WARNING("On 32 bit platform, linear memory can't reach maximum "
+                    "size of 4GB\n");
+        return NULL;
+    }
+#endif
+
     if (mapped_mem) {
         new_mem = os_mremap(mapped_mem, old_size, new_size);
     }
@@ -1589,7 +1597,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;
@@ -1611,7 +1619,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;
@@ -1619,12 +1627,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;
@@ -1902,7 +1910,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
@@ -1955,7 +1963,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;

+ 65 - 9
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
@@ -1501,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
@@ -1740,6 +1743,45 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
     wasm_exec_env_destroy(exec_env);
 }
 
+#if WAMR_ENABLE_COPY_CALLSTACK != 0
+uint32
+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
+     * 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_copy_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) {
+        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, error_buf,
+                                  error_buf_size);
+    }
+#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
+
 bool
 wasm_runtime_init_thread_env(void)
 {
@@ -2243,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)
@@ -3835,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;
@@ -4458,8 +4513,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:
         {
@@ -7793,7 +7849,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

+ 135 - 14
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)
 {
@@ -464,19 +583,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,6 +758,13 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
 WASM_RUNTIME_API_EXTERN void
 wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
 
+#if WAMR_ENABLE_COPY_CALLSTACK != 0
+WASM_RUNTIME_API_EXTERN uint32_t
+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 */
 WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
 wasm_runtime_get_module_inst(WASMExecEnv *exec_env);
@@ -678,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);
 

+ 7 - 0
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:
             {

+ 1 - 1
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))) {                  \

+ 64 - 26
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 */
@@ -1790,7 +1792,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)) {
@@ -2487,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
@@ -2498,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);
@@ -3050,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)
 {
@@ -3246,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")
@@ -3524,12 +3557,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
@@ -3693,8 +3723,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) {
@@ -3732,8 +3762,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) {
@@ -3844,7 +3873,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;
@@ -3881,7 +3910,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.")) {
@@ -3908,12 +3938,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;
         }
@@ -3982,8 +4007,21 @@ 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
+#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
                relocation->symbol_name */
             LLVMSectionIteratorRef contain_section;

+ 22 - 0
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

+ 48 - 44
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);
 

+ 3 - 3
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);

+ 44 - 20
core/iwasm/compilation/aot_emit_numberic.c

@@ -653,15 +653,22 @@ compile_int_sub(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
 }
 
 static LLVMValueRef
-compile_int_mul(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
-                bool is_i32)
+compile_int_mul(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
+                LLVMValueRef left, LLVMValueRef right, bool is_i32)
 {
     /* If one of the operands is 0, just return constant 0 */
     if (IS_CONST_ZERO(left) || IS_CONST_ZERO(right))
         return is_i32 ? I32_ZERO : I64_ZERO;
 
     /* Build mul */
-    return LLVMBuildMul(comp_ctx->builder, left, right, "mul");
+    LLVMTypeRef param_types[2];
+    param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
+
+    LLVMValueRef res;
+    LLVM_BUILD_OP_OR_INTRINSIC(Mul, left, right, res,
+                               is_i32 ? "i32.mul" : "i64.mul", "mul", false);
+
+    return res;
 }
 
 static bool
@@ -679,8 +686,9 @@ compile_op_int_arithmetic(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
                               "compile int sub fail.");
             return true;
         case INT_MUL:
-            DEF_INT_BINARY_OP(compile_int_mul(comp_ctx, left, right, is_i32),
-                              "compile int mul fail.");
+            DEF_INT_BINARY_OP(
+                compile_int_mul(comp_ctx, func_ctx, left, right, is_i32),
+                "compile int mul fail.");
             return true;
         case INT_DIV_S:
         case INT_DIV_U:
@@ -726,43 +734,57 @@ fail:
 }
 
 static LLVMValueRef
-compile_int_shl(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
-                bool is_i32)
+compile_int_shl(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
+                LLVMValueRef left, LLVMValueRef right, bool is_i32)
 {
     LLVMValueRef res;
 
     SHIFT_COUNT_MASK;
 
     /* Build shl */
-    LLVM_BUILD_OP(Shl, left, right, res, "shl", NULL);
+    LLVMTypeRef param_types[2];
+    param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
+
+    LLVM_BUILD_OP_OR_INTRINSIC(Shl, left, right, res,
+                               is_i32 ? "i32.shl" : "i64.shl", "shl", false);
 
     return res;
 }
 
 static LLVMValueRef
-compile_int_shr_s(AOTCompContext *comp_ctx, LLVMValueRef left,
-                  LLVMValueRef right, bool is_i32)
+compile_int_shr_s(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
+                  LLVMValueRef left, LLVMValueRef right, bool is_i32)
 {
     LLVMValueRef res;
 
     SHIFT_COUNT_MASK;
 
     /* Build shl */
-    LLVM_BUILD_OP(AShr, left, right, res, "shr_s", NULL);
+    LLVMTypeRef param_types[2];
+    param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
+
+    LLVM_BUILD_OP_OR_INTRINSIC(AShr, left, right, res,
+                               is_i32 ? "i32.shr_s" : "i64.shr_s", "shr_s",
+                               false);
 
     return res;
 }
 
 static LLVMValueRef
-compile_int_shr_u(AOTCompContext *comp_ctx, LLVMValueRef left,
-                  LLVMValueRef right, bool is_i32)
+compile_int_shr_u(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
+                  LLVMValueRef left, LLVMValueRef right, bool is_i32)
 {
     LLVMValueRef res;
 
     SHIFT_COUNT_MASK;
 
     /* Build shl */
-    LLVM_BUILD_OP(LShr, left, right, res, "shr_u", NULL);
+    LLVMTypeRef param_types[2];
+    param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
+
+    LLVM_BUILD_OP_OR_INTRINSIC(LShr, left, right, res,
+                               is_i32 ? "i32.shr_u" : "i64.shr_u", "shr_u",
+                               false);
 
     return res;
 }
@@ -814,16 +836,18 @@ compile_op_int_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
 {
     switch (shift_op) {
         case INT_SHL:
-            DEF_INT_BINARY_OP(compile_int_shl(comp_ctx, left, right, is_i32),
-                              NULL);
+            DEF_INT_BINARY_OP(
+                compile_int_shl(comp_ctx, func_ctx, left, right, is_i32), NULL);
             return true;
         case INT_SHR_S:
-            DEF_INT_BINARY_OP(compile_int_shr_s(comp_ctx, left, right, is_i32),
-                              NULL);
+            DEF_INT_BINARY_OP(
+                compile_int_shr_s(comp_ctx, func_ctx, left, right, is_i32),
+                NULL);
             return true;
         case INT_SHR_U:
-            DEF_INT_BINARY_OP(compile_int_shr_u(comp_ctx, left, right, is_i32),
-                              NULL);
+            DEF_INT_BINARY_OP(
+                compile_int_shr_u(comp_ctx, func_ctx, left, right, is_i32),
+                NULL);
             return true;
         case INT_ROTL:
             DEF_INT_BINARY_OP(

+ 36 - 11
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"));
@@ -1720,7 +1719,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 +2353,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;
     }
 
@@ -2521,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();
@@ -2664,12 +2664,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;
 
@@ -2736,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;
 
@@ -2980,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 = "";
         }
@@ -3334,6 +3354,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);
 
@@ -3407,7 +3432,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) {

+ 3 - 0
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;
 

+ 6 - 1
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<no-verify-fixpoint>"
+#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 {

+ 11 - 0
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<LLVMTargetMachineRef>(targetmachine);
 }
 

+ 4 - 0
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:

+ 1 - 1
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-")

+ 1 - 1
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;
     }
 

+ 10 - 10
core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp

@@ -423,7 +423,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list,
 
 /**
  * Encode detecting compare result register according to condition code
- * and then jumping to suitable label when the condtion is met
+ * and then jumping to suitable label when the condition is met
  *
  * @param cc the compiler context
  * @param a the assembler to emit the code
@@ -431,7 +431,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list,
  * @param label_src the index of src label
  * @param op the opcode of condition operation
  * @param r1 the label info when condition is met
- * @param r2 the label info when condition is unmet, do nonthing if VOID
+ * @param r2 the label info when condition is unmet, do nothing if VOID
  * @param is_last_insn if current insn is the last insn of current block
  *
  * @return true if success, false if failed
@@ -2589,7 +2589,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src,
                 if (reg_no2_src == REG_EDX_IDX) {
                     /* convert `REM_S edx, eax, edx` into
                        `mov esi, edx` and `REM_S edx eax, rsi` to
-                       avoid overwritting edx when a.cdq() */
+                       avoid overwriting edx when a.cdq() */
                     a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]);
                     reg_no2_src = REG_I32_FREE_IDX;
                 }
@@ -2609,7 +2609,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src,
                 if (reg_no2_src == REG_EDX_IDX) {
                     /* convert `REM_U edx, eax, edx` into
                        `mov esi, edx` and `REM_U edx eax, rsi` to
-                       avoid overwritting edx when unsigned extend
+                       avoid overwriting edx when unsigned extend
                        eax to edx:eax */
                     a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]);
                     reg_no2_src = REG_I32_FREE_IDX;
@@ -5602,7 +5602,7 @@ fail:
             a.jmp(imm);                                                    \
             if (!err_handler->err) {                                       \
                 /* The offset written by asmjit is always 0, we patch it   \
-                   again, 6 is the size of jmp instruciton */              \
+                   again, 6 is the size of jmp instruction */              \
                 stream = (char *)a.code()->sectionById(0)->buffer().data() \
                          + a.code()->sectionById(0)->buffer().size() - 6;  \
                 _offset = label_offsets[label_dst]                         \
@@ -6169,7 +6169,7 @@ fail:
  * Replace all the jmp address pre-saved when the code cache hasn't been
  * allocated with actual address after code cache allocated
  *
- * @param cc compiler context containting the allocated code cacha info
+ * @param cc compiler context containing the allocated code cacha info
  * @param jmp_info_list the jmp info list
  */
 static void
@@ -6557,7 +6557,7 @@ at_cmpxchg_r_ra_base_r_offset_imm(x86::Assembler &a, uint32 bytes_dst,
  * @param a the assembler to emit the code
  * @param bytes_dst the bytes number of the data to actual operated on(load,
  * compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64)
- * @param data_xchg the immediate data for exchange(conditionally replacment
+ * @param data_xchg the immediate data for exchange(conditionally replacement
  * value)
  * @param reg_no_base the no of register that stores the base address
  *        of src&dst memory
@@ -6587,7 +6587,7 @@ at_cmpxchg_imm_ra_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst,
  * @param a the assembler to emit the code
  * @param bytes_dst the bytes number of the data to actual operated on(load,
  * compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64)
- * @param data_xchg the immediate data for exchange(conditionally replacment
+ * @param data_xchg the immediate data for exchange(conditionally replacement
  * value)
  * @param reg_no_base the no of register that stores the base address
  *        of src&dst memory
@@ -8820,7 +8820,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx)
 
         /* If yes, set eax to 0, return to caller */
 
-        /* Pop all integer arument registers */
+        /* Pop all integer argument registers */
         for (i = 0; i < MAX_REG_INTS; i++) {
             a.pop(regs_i64[reg_idx_of_int_args[i]]);
         }
@@ -9084,7 +9084,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx)
         a.mov(m, x86::rdx);
     }
 
-    /* Pop all integer arument registers */
+    /* Pop all integer argument registers */
     for (i = 0; i < MAX_REG_INTS; i++) {
         a.pop(regs_i64[reg_idx_of_int_args[i]]);
     }

+ 1 - 1
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;
     }
 

+ 1 - 1
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) {

+ 7 - 1
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)

+ 2 - 2
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;

+ 5 - 5
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.

+ 4 - 4
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.
  *

+ 9 - 0
core/iwasm/include/aot_comp_option.h

@@ -8,6 +8,10 @@
 
 #include <stdint.h>
 
+#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
@@ -69,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;
@@ -88,4 +93,8 @@ typedef struct AOTCompOption {
     const char *builtin_intrinsics;
 } AOTCompOption, *aot_comp_option_t;
 
+#ifdef __cplusplus
+}
 #endif
+
+#endif /* end of __AOT_COMP_OPTION_H__ */

+ 1 - 1
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");

+ 59 - 1
core/iwasm/include/wasm_export.h

@@ -126,6 +126,21 @@ 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;
+    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;
+
+typedef WASMCApiFrame wasm_frame_t;
+
 /* WASM section */
 typedef struct wasm_section_t {
     struct wasm_section_t *next;
@@ -865,6 +880,35 @@ 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.
+ *
+ * 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
+ *
+ * @param exec_env the execution environment that containes frames
+ * @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_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.
  *
@@ -1778,6 +1822,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
@@ -2315,7 +2373,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.

+ 1 - 1
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;

+ 51 - 26
core/iwasm/interpreter/wasm_interp_classic.c

@@ -1494,10 +1494,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 */
@@ -1520,9 +1523,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 */
@@ -1540,6 +1546,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,
@@ -1583,6 +1601,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
@@ -1896,7 +1922,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,
@@ -4925,7 +4951,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);
@@ -5082,7 +5108,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);
@@ -5239,7 +5265,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);
@@ -5343,7 +5369,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);
@@ -5746,7 +5772,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();
@@ -5759,24 +5784,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 = get_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 = get_shared_heap_end_off() - dst + 1;
                         }
                         else
 #endif
@@ -5794,6 +5812,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
@@ -5813,15 +5832,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:
@@ -6642,7 +6667,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

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1848 - 134
core/iwasm/interpreter/wasm_interp_fast.c


Dosya farkı çok büyük olduğundan ihmal edildi
+ 423 - 92
core/iwasm/interpreter/wasm_loader.c


+ 37 - 3
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);
@@ -2457,7 +2472,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,
@@ -2478,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));
 
@@ -2486,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
@@ -3122,6 +3139,18 @@ 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();
+#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;
 }
@@ -4763,6 +4792,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);

+ 24 - 3
core/iwasm/interpreter/wasm_opcode.h

@@ -278,6 +278,16 @@ typedef enum WASMOpcode {
     DEBUG_OP_BREAK = 0xdc, /* debug break point */
 #endif
 
+#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 */
     WASM_OP_GC_PREFIX = 0xfb,
     WASM_OP_MISC_PREFIX = 0xfc,
@@ -779,16 +789,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_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_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 */ \
+        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_SELECT_128),         /* 0xe2 */
+
+#else
+#define DEF_EXT_V128_HANDLE()
+#endif
 /*
  * Macro used to generate computed goto tables for the C interpreter.
  */
@@ -1020,7 +1041,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

+ 56 - 7
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) {
@@ -4195,6 +4195,55 @@ 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_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
+     * 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
+           && 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);
+        buffer[count - skip_n] = record_frame;
+        cur_frame = cur_frame->prev_frame;
+        ++count;
+    }
+    return count >= skip_n ? count - skip_n : 0;
+}
+#endif // WAMR_ENABLE_COPY_CALLSTACK
+
 #if WASM_ENABLE_DUMP_CALL_STACK != 0
 bool
 wasm_interp_create_call_stack(struct WASMExecEnv *exec_env)

+ 8 - 0
core/iwasm/interpreter/wasm_runtime.h

@@ -738,6 +738,14 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
 }
 
 #if WASM_ENABLE_DUMP_CALL_STACK != 0
+
+#if WAMR_ENABLE_COPY_CALLSTACK != 0
+uint32
+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
 wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);
 

+ 3 - 3
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();

+ 1 - 1
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);

+ 1 - 1
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;

+ 1 - 1
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);

+ 62 - 28
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);
+        (void)snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status);
         write_packet(server, tmpbuf);
         os_mutex_unlock(&tmpbuf_lock);
         return;
@@ -400,17 +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%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 (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);
@@ -624,7 +657,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;

+ 2 - 2
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);

+ 7 - 0
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 "")

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor