Compare commits

..

No commits in common. "442ea20a0086b98249c4338decfaa00c615dea67" and "e3b024413d61823ec135c813ca4a0966399fe51b" have entirely different histories.

387 changed files with 6230 additions and 13609 deletions

View File

@ -1,12 +1,16 @@
# for now, it is used to speed up wasi-nn tests only.
# you shall adapt below rules to incoming requirements
**/build
**/tmp.*
build
*/build
*/*/build
*/*/*/build
*/*/*/*/build
*/*/*/*/*/build
*/*/*/*/*/*/build
.*
**/*.gguf
/core/deps/
!/core/deps/tensorflow-src
/samples
/tests
core/deps
!core/deps/tensorflow-src
samples
tests

View File

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

View File

@ -1,125 +0,0 @@
# 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: |
echo "Downloading wasi-sdk for Ubuntu..."
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
echo "Extracting wasi-sdk..."
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk
echo "Downloading wabt for Ubuntu..."
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz
echo "Extracting wabt..."
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.37 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on ubuntu"
working-directory: /opt
- name: Set up wasi-sdk and wabt on macOS-13 (intel)
if: ${{ inputs.os == 'macos-13' }}
shell: bash
run: |
echo "Downloading wasi-sdk for macOS-13..."
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-macos.tar.gz
echo "Extracting wasi-sdk..."
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk
echo "Downloading wabt for macOS-13..."
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz
echo "Extracting wabt..."
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.36 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.36 installed on macos-13"
working-directory: /opt
- name: Set up wasi-sdk and wabt on macOS-14 (arm64)
if: ${{ inputs.os == 'macos-14' }}
shell: bash
run: |
echo "Downloading wasi-sdk for macOS-14..."
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-arm64-macos.tar.gz
echo "Extracting wasi-sdk..."
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk
echo "Downloading wabt for macOS-14..."
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-macos-14.tar.gz
echo "Extracting wabt..."
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.37 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on macos-14"
working-directory: /opt
- name: Set up wasi-sdk and wabt on Windows
if: ${{ startsWith(inputs.os, 'windows') }}
shell: bash
run: |
choco install -y wget
mkdir -p /opt/wasi-sdk
mkdir -p /opt/wabt
echo "Downloading wasi-sdk for Windows..."
wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-windows.tar.gz
echo "Extracting wasi-sdk..."
tar --strip-components=1 -xf wasi-sdk.tar.gz -C /opt/wasi-sdk
echo "Downloading wabt for Windows..."
wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz
echo "Extracting wabt..."
tar --strip-components=1 -xf wabt.tar.gz -C /opt/wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on Windows"

View File

@ -137,8 +137,7 @@ jobs:
- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest'
run: |
# Follow the symlink to the actual binary file
tar --dereference -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
tar 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

View File

@ -65,7 +65,6 @@ 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
@ -89,6 +88,14 @@ 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

View File

@ -172,12 +172,6 @@ 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: |
@ -185,7 +179,6 @@ 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 \

View File

@ -73,8 +73,7 @@ jobs:
- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest' && inputs.release
run: |
# Follow the symlink to the actual binary file
tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
working-directory: wamr-compiler/build

View File

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

View File

@ -53,7 +53,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.29.0
uses: github/codeql-action/init@v3.27.6
with:
languages: ${{ matrix.language }}
@ -70,7 +70,7 @@ jobs:
- run: |
./.github/scripts/codeql_buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.29.0
uses: github/codeql-action/analyze@v3.27.6
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.29.0
uses: github/codeql-action/upload-sarif@v3.27.6
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.2
uses: actions/upload-artifact@v4.4.3
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}

View File

@ -19,7 +19,7 @@ permissions:
jobs:
compliance_job:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v4

View File

@ -74,12 +74,6 @@ 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
@ -158,12 +152,10 @@ 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",
"-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=1",
]
os: [ubuntu-22.04]
platform: [android, linux]
@ -179,9 +171,11 @@ 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/fast interpreter mode
# SIMD only on JIT/AOT 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"
@ -259,9 +253,6 @@ jobs:
platform: android
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
platform: android
# android does not support WAMR_BUILD_SHARED in its CMakeLists.txt.
- make_options_feature: "-DWAMR_BUILD_SHARED=1"
platform: android
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
@ -315,14 +306,17 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04]
build_target: [
"X86_64",
"X86_32",
]
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
@ -343,10 +337,19 @@ jobs:
if: (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: 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: Build wamrc
run: |
@ -355,16 +358,10 @@ 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 .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
cmake ..
cmake --build . --config Release --parallel 4
ctest
working-directory: tests/unit
@ -391,6 +388,14 @@ 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 }}
@ -416,10 +421,12 @@ 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: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- 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 wamrc
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
@ -437,11 +444,6 @@ 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:
[
@ -453,14 +455,34 @@ 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
@ -472,19 +494,12 @@ 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
@ -610,6 +625,10 @@ 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 }}
@ -618,6 +637,51 @@ jobs:
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
running_mode: aot
test_option: $WAMR_COMPILER_TEST_OPTIONS
exclude:
# incompatible modes and features
# classic-interp and fast-interp don'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
# fast-jit doesn't support multi module, simd
- running_mode: "fast-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $SIMD_TEST_OPTIONS
# multi-tier-jit doesn't support multi module, simd
- running_mode: "multi-tier-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $SIMD_TEST_OPTIONS
# fast-jit and multi-tier-jit don't support GC
- running_mode: "fast-jit"
test_option: $GC_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $GC_TEST_OPTIONS
# fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Memory64
- running_mode: "fast-interp"
test_option: $MEMORY64_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $MEMORY64_TEST_OPTIONS
- running_mode: "jit"
test_option: $MEMORY64_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $MEMORY64_TEST_OPTIONS
# aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory
- running_mode: "aot"
test_option: $MULTI_MEMORY_TEST_OPTIONS
- running_mode: "fast-interp"
test_option: $MULTI_MEMORY_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $MULTI_MEMORY_TEST_OPTIONS
- running_mode: "jit"
test_option: $MULTI_MEMORY_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $MULTI_MEMORY_TEST_OPTIONS
steps:
- name: checkout
@ -635,9 +699,20 @@ jobs:
- name: download and install wasi-sdk
if: matrix.test_option == '$WASI_TEST_OPTIONS'
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
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
- name: set env variable(if llvm are used)
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
@ -675,7 +750,7 @@ jobs:
- name: Build WASI thread tests
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: bash build.sh
run: bash build.sh --sysroot "$SYSROOT_PATH"
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
- name: build socket api tests
@ -721,3 +796,123 @@ jobs:
eval $(opam env)
./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites
test-wamr-ide:
needs:
[
build_iwasm
]
runs-on: ubuntu-22.04
env:
PYTHON_VERSION: '3.10'
PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz
steps:
- name: checkout
uses: actions/checkout@v4
- name: install dependencies
run: |
rustup target add wasm32-wasi
sudo apt update && sudo apt-get install -y lld ninja-build
npm install
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: code style check
run: |
npm install --save-dev prettier
npm run prettier-format-check
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: build iwasm with source debugging feature
run: |
mkdir build
cd build
cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1
make
working-directory: product-mini/platforms/linux
- name: Cache LLDB
id: cache-lldb
uses: actions/cache@v4
env:
cache-name: cache-lldb-vscode
with:
path: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
key: ${{ env.cache-name }}-${{ hashFiles('build-scripts/lldb_wasm.patch') }}-${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }}
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
name: get stand-alone python ubuntu
run: |
wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
tar -xvf python.tar.gz
working-directory: core/deps
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
name: download llvm
run: |
wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
working-directory: core/deps
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
name: apply wamr patch
run: |
git init
git config user.email "action@github.com"
git config user.name "github action"
git apply ../../../build-scripts/lldb_wasm.patch
working-directory: core/deps/llvm-project
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
name: build lldb ubuntu
run: |
echo "start to build lldb..."
mkdir -p wamr-lldb
cmake -S ./llvm -B build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
-DLLVM_BUILD_DOCS:BOOL=OFF \
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
-DLLVM_BUILD_TESTS:BOOL=OFF \
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
-DLLVM_ENABLE_LLD:BOOL=ON \
-DLLDB_ENABLE_PYTHON:BOOL=ON \
-DLLDB_EMBED_PYTHON_HOME=ON \
-DLLDB_PYTHON_HOME=.. \
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
cmake --build build --target lldb install --parallel $(nproc)
working-directory: core/deps/llvm-project
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
name: copy lldb to extension folder
run: |
mkdir -p bin
mkdir -p lib
cp ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/package.json ./
cp -r ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/syntaxes/ ./
cp ../../../../../../core/deps/llvm-project/build/bin/lldb* bin
cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so lib
cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so.* lib
cp -R ../../../../../../core/deps/llvm-project/build/lib/lldb-python lib
cp -R ../../../../../../core/deps/python/lib/python* lib
cp ../../../../../../core/deps/python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 lib
working-directory: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
- name: run tests
timeout-minutes: 5
run: xvfb-run npm run test
working-directory: test-tools/wamr-ide/VSCode-Extension

View File

@ -46,14 +46,11 @@ concurrency:
cancel-in-progress: true
env:
# 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"
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"
permissions:
contents: read
@ -217,82 +214,60 @@ jobs:
working-directory: product-mini/platforms/${{ matrix.platform }}
build_samples_wasm_c_api:
needs:
[
build_iwasm,
build_llvm_libraries_on_intel_macos,
build_wamrc,
]
needs: [build_iwasm]
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options: [
$AOT_BUILD_OPTIONS,
# Running modes supported
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
# Running modes unsupported
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
#$AOT_BUILD_OPTIONS,
]
os: [macos-13]
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
wasi_sdk_release:
[
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
]
wabt_release:
[
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: 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'))
- name: download and install wabt
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
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 Sample [wasm-c-api]
run: |
VERBOSE=1
cmake -S . -B build ${{ matrix.make_options }}
cmake --build build --config Debug --parallel 4
cmake --build build --config Release --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 }}
@ -302,10 +277,19 @@ jobs:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- 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: Build Sample [basic]
run: |
@ -372,13 +356,12 @@ 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 --verbose
cmake --build . --config Debug --parallel 4
./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

View File

@ -88,14 +88,14 @@ jobs:
uses: actions/checkout@v4
with:
repository: apache/nuttx
ref: releases/12.9
ref: releases/12.6
path: nuttx
- name: Checkout NuttX Apps
uses: actions/checkout@v4
with:
repository: apache/nuttx-apps
ref: releases/12.9
ref: releases/12.6
path: apps
- name: Checkout WAMR

View File

@ -49,14 +49,10 @@ 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 -DWAMR_BUILD_SIMD=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_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
@ -68,7 +64,7 @@ jobs:
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: ubuntu-22.04
os: "ubuntu-20.04"
arch: "X86"
build_iwasm:
@ -101,12 +97,12 @@ jobs:
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
# doesn't support
"-DWAMR_BUILD_SIMD=0",
# "-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_SGX_IPFS=1",
]
os: [ubuntu-22.04]
os: [ubuntu-20.04]
platform: [linux-sgx]
exclude:
# incompatible mode and feature
@ -114,14 +110,22 @@ 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
@ -146,29 +150,69 @@ jobs:
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
]
os: [ubuntu-22.04]
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",
]
iwasm_make_options_feature: [
# Features to be tested: IPFS
"-DWAMR_BUILD_SGX_IPFS=1",
]
platform: [linux-sgx]
include:
- os: ubuntu-22.04
- os: ubuntu-20.04
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- 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 SGX SDK and necessary libraries
uses: ./.github/actions/install-linux-sgx
with:
os: ${{ matrix.os }}
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
- name: Build iwasm for testing samples
run: |
@ -196,61 +240,59 @@ jobs:
- name: Build wamrc only for testing samples in aot mode
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
run: |
cmake -S . -B build
cmake --build build --config Release --parallel 4
cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
working-directory: wamr-compiler
- name: Build Sample [file]
run: |
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
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
- 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: ${{ matrix.os }}
runs-on: ubuntu-20.04
strategy:
matrix:
#(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]
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 }}"]
exclude:
# classic-interp, fast-interp and fast-jit don't support simd
- running_mode: "classic-interp"
test_option: $SIMD_TEST_OPTIONS
test_option: "-x -p -s spec -S -P"
- running_mode: "fast-interp"
test_option: $SIMD_TEST_OPTIONS
test_option: "-x -p -s spec -S -P"
- running_mode: "fast-jit"
test_option: $SIMD_TEST_OPTIONS
test_option: "-x -p -s spec -S -P"
# classic-interp, fast-interp and fast jit don't support XIP
- running_mode: "classic-interp"
test_option: $XIP_TEST_OPTIONS
test_option: "-x -p -s spec -X -P"
- running_mode: "fast-interp"
test_option: $XIP_TEST_OPTIONS
test_option: "-x -p -s spec -X -P"
- running_mode: "fast-jit"
test_option: $XIP_TEST_OPTIONS
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
test_option: "-x -p -s spec -X -P"
steps:
- name: checkout
@ -274,44 +316,22 @@ jobs:
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install SGX SDK and necessary libraries
uses: ./.github/actions/install-linux-sgx
with:
os: ${{ matrix.os }}
#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
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
- name: install for wabt compilation
run: sudo apt update && sudo apt install -y ninja-build
- name: run spec tests
run: |
set +e
source /opt/intel/sgxsdk/environment
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
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites

View File

@ -57,33 +57,23 @@ permissions:
contents: read
jobs:
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:
build:
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
@ -99,49 +89,17 @@ 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_iwasm, build_wamrc]
needs: [build]
strategy:
fail-fast: false
matrix:
running_mode: ["classic-interp", "fast-interp"]
running_mode:
[
"classic-interp",
"fast-interp",
]
test_option:
[
$DEFAULT_TEST_OPTIONS,
@ -172,10 +130,6 @@ jobs:
run: ./build.sh
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
- name: install wget
shell: bash
run: choco install wget
- name: run tests
shell: bash
timeout-minutes: 20

View File

@ -36,18 +36,27 @@ env:
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
# For Spec Test
DEFAULT_TEST_OPTIONS: "-s spec -b -P"
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -P -M"
SIMD_TEST_OPTIONS: "-s spec -b -P -S"
THREADS_TEST_OPTIONS: "-s spec -b -P -p"
X86_32_TARGET_TEST_OPTIONS: "-m x86_32"
# FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
DEFAULT_TEST_OPTIONS: "-s spec -P"
MULTI_MODULES_TEST_OPTIONS: "-s spec -M -P"
SIMD_TEST_OPTIONS: "-s spec -S -P"
THREADS_TEST_OPTIONS: "-s spec -p -P"
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
WASI_TEST_OPTIONS: "-s wasi_certification -w"
permissions:
contents: read
jobs:
build_llvm_libraries_on_ubuntu:
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:
permissions:
contents: read
actions: write
@ -57,13 +66,16 @@ jobs:
arch: "X86"
build_wamrc:
needs: build_llvm_libraries_on_ubuntu
needs:
[
build_llvm_libraries_on_ubuntu_2004,
]
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
- os: ubuntu-20.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
@ -94,7 +106,10 @@ jobs:
working-directory: wamr-compiler
build_iwasm:
needs: build_llvm_libraries_on_ubuntu
needs:
[
build_llvm_libraries_on_ubuntu_2004,
]
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -127,9 +142,8 @@ jobs:
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_MEMORY64=1",
"-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=1",
]
os: [ubuntu-22.04]
os: [ubuntu-20.04]
platform: [android, linux]
exclude:
# incompatible feature and platform
@ -226,8 +240,8 @@ jobs:
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
platform: android
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
- os: ubuntu-20.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
steps:
- name: checkout
@ -360,7 +374,12 @@ jobs:
working-directory: wamr/product-mini/platforms/linux
build_samples_wasm_c_api:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
needs:
[
build_iwasm,
build_llvm_libraries_on_ubuntu_2004,
build_wamrc,
]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -376,10 +395,18 @@ jobs:
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
]
os: [ubuntu-22.04]
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",
]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
- os: ubuntu-20.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
exclude:
- make_options: $MULTI_TIER_JIT_BUILD_OPTIONS
sanitizer: asan
@ -404,11 +431,12 @@ 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: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- 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 wamrc
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
run: |
@ -428,23 +456,44 @@ jobs:
working-directory: samples/wasm-c-api
build_samples_others:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
needs:
[
build_iwasm,
build_llvm_libraries_on_ubuntu_2004,
build_wamrc,
]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
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",
]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
- os: ubuntu-20.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- 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
@ -541,21 +590,17 @@ 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
# 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: 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: |
@ -567,12 +612,18 @@ jobs:
./shared_heap_test --aot
test:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
needs:
[
build_iwasm,
build_llvm_libraries_on_ubuntu_2004,
build_llvm_libraries_on_ubuntu_2204,
build_wamrc,
]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
os: [ubuntu-20.04, ubuntu-22.04]
sanitizer: ["", "ubsan", "asan", "tsan"]
running_mode:
[
@ -591,12 +642,22 @@ 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.outputs.cache_key }}
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.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
@ -616,20 +677,44 @@ jobs:
sanitizer: tsan
- running_mode: "multi-tier-jit"
sanitizer: tsan
# simd128.h brings ubsan errors
# like: negation of XXXcannot be represented in type 'long int';
# cast to an unsigned type to negate this value to itself
# classic-interp and fast-interp don't support simd
- running_mode: "classic-interp"
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-interp"
sanitizer: ubsan
test_option: $SIMD_TEST_OPTIONS
# llvm jit doesn't support multi module
- running_mode: "jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
# fast-jit doesn't support multi module, simd
- running_mode: "fast-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $SIMD_TEST_OPTIONS
# multi-tier-jit doesn't support multi module, simd
- running_mode: "multi-tier-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $SIMD_TEST_OPTIONS
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
- name: download and install wasi-sdk
if: matrix.test_option == '$WASI_TEST_OPTIONS'
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
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
- name: set env variable(if llvm are used)
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
@ -675,12 +760,12 @@ jobs:
- name: Build WASI thread tests
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: bash build.sh
run: bash build.sh --sysroot "$SYSROOT_PATH"
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
run: bash build.sh --sysroot "$SYSROOT_PATH"
working-directory: ./core/iwasm/libraries/lib-wasi-threads/stress-test/
- name: build socket api tests

View File

@ -58,6 +58,16 @@ 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
@ -90,6 +100,18 @@ 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
@ -113,7 +135,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
@ -128,6 +150,18 @@ 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
@ -166,6 +200,19 @@ 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
@ -192,33 +239,41 @@ jobs:
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
# Let's disable it for now and reopen it when the actual requirement arises.
# Please ensure all dependencies have been updated before reopening.
#
# # vscode extension cross-platform
# release_wamr_ide_vscode_ext:
# permissions:
# contents: write # upload release artifact
# needs: [create_tag, create_release]
# uses: ./.github/workflows/build_wamr_vscode_ext.yml
# secrets: inherit
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
# vscode extension cross-platform
release_wamr_ide_vscode_ext:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_vscode_ext.yml
secrets: inherit
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}
# #
# # vscode extension docker images package
# release_wamr_ide_docker_images_package:
# permissions:
# contents: write # upload release artifact
# needs: [create_tag, create_release]
# uses: ./.github/workflows/build_docker_images.yml
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
#
# vscode extension docker images package
release_wamr_ide_docker_images_package:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_docker_images.yml
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}
#
# WAMR_LLDB
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

View File

@ -127,8 +127,7 @@ jobs:
wamr_feature_option:
# Empty option for default
- { option: "", mode: "" }
# need to install menhir
# - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
- { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
exclude:
# XIP is not fully supported yet on RISCV64, some relocations can not be resolved
@ -146,14 +145,14 @@ jobs:
uses: actions/checkout@v4
with:
repository: apache/nuttx
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }}
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }}
path: nuttx
- name: Checkout NuttX Apps
uses: actions/checkout@v4
with:
repository: apache/nuttx-apps
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }}
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }}
path: apps
- name: Checkout WAMR
@ -183,11 +182,33 @@ 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
run: |
cmake -B build -DWAMR_BUILD_SHRUNK_MEMORY=0 -S .
cmake -Bbuild .
cmake --build build
# the nuttx version we use for xtensa requires esptool.py newer than
@ -329,7 +350,7 @@ jobs:
- name: upload the log
if: always()
uses: actions/upload-artifact@v4.6.2
uses: actions/upload-artifact@v4.4.3
with:
name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
path: log

View File

@ -39,7 +39,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0
uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # 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@2847b7f7ab9f48fc49eca90a53fff6007285f399
uses: github/codeql-action/upload-sarif@6f9e628e6f9a18c785dd746325ba455111df1b67 # v2.2.4
with:
sarif_file: results.sarif

View File

@ -1,18 +1,14 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required (VERSION 3.14)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
cmake_minimum_required (VERSION 3.0)
if(ESP_PLATFORM)
include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt)
return()
endif()
project (iwasm LANGUAGES C)
set(CMAKE_CXX_STANDARD 17)
project (iwasm)
set (CMAKE_VERBOSE_MAKEFILE OFF)
@ -20,6 +16,13 @@ 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 "")
@ -99,11 +102,6 @@ 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,40 +150,56 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
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>
)
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)
if (MSVC)
add_definitions(-DCOMPILING_WASM_RUNTIME_API=1)
endif ()
if (MINGW)
target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32)
target_link_libraries(vmlib PRIVATE ws2_32)
# STATIC LIBRARY
if (WAMR_BUILD_STATIC)
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
target_include_directories(iwasm_static INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
target_link_libraries(iwasm_static INTERFACE boringssl_crypto)
endif ()
if (MINGW)
target_link_libraries (iwasm_static PRIVATE ws2_32)
endif ()
if (WIN32)
target_link_libraries(iwasm_static PRIVATE ntdll)
endif()
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
endif ()
if (WIN32)
target_link_libraries(vmlib PRIVATE ntdll)
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 INTERFACE ${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 ()
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 (MINGW)
target_link_libraries(iwasm_shared INTERFACE -lWs2_32 -lwsock32)
target_link_libraries(iwasm_shared PRIVATE ws2_32)
endif ()
set_version_info (vmlib)
if (WIN32)
target_link_libraries(iwasm_shared PRIVATE ntdll)
endif()
install (TARGETS vmlib
EXPORT iwasmTargets
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
endif ()
install_iwasm_package ()
# 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)

View File

@ -22,7 +22,7 @@
# If none of the later patterns match, assign to anyone. This team is the
# parent of all the other teams and automatically includes everyone on those
# teams.
* @loganek @lum1n0us @no1wudi @TianlongLiang @wenyongh @xujuntwt95329 @yamt
* @loganek @lum1n0us @no1wudi @wenyongh @xujuntwt95329 @yamt
# Some parts of the project require more specialized knowledge. In those areas
# we designate smaller groups who are more likely to be aware of who's working

View File

@ -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 separate folder of source files to host different platform logic.
- Avoid use macros for different platforms. Use seperate folder of source files to host diffeent 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.

View File

@ -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 memory/shared memory support, text size from bloaty)
- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memroy/shared memroy support, text size from bloaty)
* ~58.9K for fast interpreter
* ~56.3K for classic interpreter
* ~29.4K for aot runtime

File diff suppressed because it is too large Load Diff

View File

@ -112,11 +112,17 @@ 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 ""
]
@ -211,11 +217,11 @@ def repackage_llvm_windows(llvm_dir):
if not packs_path:
raise Exception("Didn't find any LLVM-* package")
return
llvm_package_path = f"_CPack_Packages/win64/NSIS/{packs_path[0].name}"
windows_package_dir = build_dir.joinpath(llvm_package_path).resolve()
# mv package dir outside of build
# mv package dir outside of build
shutil.move(str(windows_package_dir), str(llvm_dir))
# rm -r build
shutil.rmtree(str(build_dir))
@ -225,7 +231,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")
@ -294,17 +300,17 @@ def main():
"arc": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/18.x",
"branch": "release/15.x",
},
"xtensa": {
"repo": "https://github.com/espressif/llvm-project.git",
"repo_ssh": "git@github.com:espressif/llvm-project.git",
"branch": "xtensa_release_18.1.2",
"branch": "xtensa_release_17.0.1",
},
"default": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/18.x",
"branch": "release/15.x",
},
}

View File

@ -131,12 +131,6 @@ 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)
@ -157,9 +151,6 @@ 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()
@ -171,68 +162,16 @@ if (WAMR_BUILD_LINUX_PERF EQUAL 1)
endif ()
endif ()
if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
# Enable shrunk memory by default
set (WAMR_BUILD_SHRUNK_MEMORY 1)
endif ()
########################################
# 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 ()
@ -263,7 +202,32 @@ 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_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")
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")
endif ()
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
message (" Multiple modules enabled")
else ()
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
message (" spec test compatible mode is on")
@ -272,23 +236,41 @@ 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")
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
# Enable bulk memory by default
set (WAMR_BUILD_BULK_MEMORY 1)
endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
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")
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
message (" Bulk memory feature enabled")
else ()
message (" Libc WASI disabled")
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
message (" Bulk memory feature disabled")
endif ()
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()
if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
endif()
add_definitions (-DWASM_ENABLE_MEMORY64=1)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
message (" Memory64 memory enabled")
endif ()
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
message (" Multi memory enabled")
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
message (" Thread manager enabled")
@ -308,53 +290,6 @@ 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")
else ()
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
else ()
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()
if (WAMR_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.*")
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
endif()
add_definitions (-DWASM_ENABLE_MEMORY64=1)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
endif ()
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_MINI_LOADER EQUAL 1)
add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
message (" WASM mini loader enabled")
@ -382,14 +317,12 @@ else ()
message (" Wakeup of blocking operations enabled")
endif ()
if (WAMR_BUILD_SIMD EQUAL 1)
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)
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
add_definitions (-DWASM_ENABLE_SIMD=1)
message (" SIMD enabled")
else ()
message (" SIMD disabled due to not supported on target RISCV64")
endif ()
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
endif ()
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
@ -416,11 +349,16 @@ 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()
@ -432,6 +370,7 @@ 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 ()
@ -660,51 +599,3 @@ endif()
if (NOT WAMR_BUILD_SANITIZER STREQUAL "")
message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled")
endif ()
if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1)
message (" Shrunk memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
message (" Shrunk memory disabled")
endif()
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"
)

View File

@ -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.14)
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

View File

@ -5,15 +5,11 @@
if (NOT CMAKE_BUILD_EARLY_EXPANSION)
if (CONFIG_IDF_TARGET_ARCH_RISCV)
if (CONFIG_IDF_TARGET_ESP32P4)
set (WAMR_BUILD_TARGET "RISCV32_ILP32F")
else ()
set (WAMR_BUILD_TARGET "RISCV32_ILP32")
endif ()
set (WAMR_BUILD_TARGET "RISCV32")
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")
@ -45,31 +41,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}/../../..)
@ -93,11 +89,7 @@ idf_component_register(SRCS ${srcs}
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
if (CONFIG_IDF_TARGET_ARCH_RISCV)
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 ()
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1)
endif ()

View File

@ -1,6 +0,0 @@
# 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")

View File

@ -1,30 +0,0 @@
# 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()

View File

@ -1 +1 @@
requests==2.32.4
requests==2.32.3

View File

@ -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 variable
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE varable
# 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,18 +168,6 @@ 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
@ -193,13 +181,6 @@ 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)

View File

@ -1,28 +0,0 @@
# 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()

View File

@ -13,8 +13,8 @@ import subprocess
import sys
import unittest
CLANG_FORMAT_CMD = "clang-format-14"
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
CLANG_FORMAT_CMD = "clang-format-12"
GIT_CLANG_FORMAT_CMD = "git-clang-format-12"
# glob style patterns
EXCLUDE_PATHS = [
@ -32,7 +32,7 @@ EXCLUDE_PATHS = [
"**/tests/wamr-test-suites/workspace/*",
]
C_SUFFIXES = [".c", ".cc", ".cpp", ".h"]
C_SUFFIXES = [".c", ".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,29 +93,20 @@ def run_clang_format(file_path: Path, root: Path) -> bool:
def run_clang_format_diff(root: Path, commits: str) -> bool:
"""
Use `clang-format-14` or `git-clang-format-14` to check code format of
Use `clang-format-12` or `git-clang-format-12` 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-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
```
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
2. Format the C/C++ source file
``` shell
cd path/to/wamr/root
clang-format-14 --style file -i path/to/file
clang-format-12 --style file -i path/to/file
```
The code wrapped by `/* clang-format off */` and `/* clang-format on */`
@ -154,7 +145,7 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
found = False
for summary in [x for x in diff_content if x.startswith("diff --git")]:
# b/path/to/file -> path/to/file
with_invalid_format = re.split(r"\s+", summary)[-1][2:]
with_invalid_format = re.split("\s+", summary)[-1][2:]
if not is_excluded(with_invalid_format):
print(f"--- {with_invalid_format} failed on code style checking.")
found = True

View File

@ -193,10 +193,6 @@
#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
@ -322,12 +318,6 @@
#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
@ -708,16 +698,4 @@ unless used elsewhere */
#define WASM_ENABLE_SHARED_HEAP 0
#endif
#ifndef WASM_ENABLE_SHRUNK_MEMORY
#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_ */

View File

@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type)
return num;
}
uint64
uint32
aot_intrinsic_clz_i64(uint64 type)
{
uint32 num = 0;
@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type)
return num;
}
uint64
uint32
aot_intrinsic_ctz_i64(uint64 type)
{
uint32 num = 0;
@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u)
return ret;
}
uint64
uint32
aot_intrinsic_popcnt_i64(uint64 u)
{
uint32 ret = 0;
@ -485,30 +485,6 @@ 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 {
@ -585,10 +561,6 @@ 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 */
@ -629,10 +601,6 @@ 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
@ -898,17 +866,6 @@ 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)) {
/*
@ -921,6 +878,9 @@ 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 {
/*

View File

@ -98,10 +98,6 @@ 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 */
@ -186,19 +182,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b);
uint32
aot_intrinsic_clz_i32(uint32 type);
uint64
uint32
aot_intrinsic_clz_i64(uint64 type);
uint32
aot_intrinsic_ctz_i32(uint32 type);
uint64
uint32
aot_intrinsic_ctz_i64(uint64 type);
uint32
aot_intrinsic_popcnt_i32(uint32 u);
uint64
uint32
aot_intrinsic_popcnt_i64(uint64 u);
float32
@ -291,18 +287,6 @@ 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);

View File

@ -10,9 +10,6 @@
#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"
@ -317,12 +314,9 @@ 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()))) {
/* Test whether the mmapped memory in the first 2 Gigabytes of the
/* The mmapped memory must be in the first 2 Gigabytes of the
process address space */
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.");
bh_assert((uintptr_t)mem < INT32_MAX);
return mem;
}
#endif
@ -590,8 +584,7 @@ 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")
|| !strcmp(target_info.arch, "aarch64"))
if (!strcmp(target_info.arch, "arm64"))
bh_strcpy_s(target_info.arch, sizeof(target_info.arch), "aarch64v8");
/* Check machine info */
@ -974,29 +967,13 @@ destroy_import_memories(AOTImportMemory *import_memories)
wasm_runtime_free(import_memories);
}
/**
* Free memory initialization data segments.
*
* @param module the AOT module containing the data
* @param data_list array of memory initialization data segments to free
* @param count number of segments in the data_list array
*/
static void
destroy_mem_init_data_list(AOTModule *module, AOTMemInitData **data_list,
uint32 count)
destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count)
{
uint32 i;
/* Free each memory initialization data segment */
for (i = 0; i < count; i++)
if (data_list[i]) {
/* If the module owns the binary data, free the bytes buffer */
if (module->is_binary_freeable && data_list[i]->bytes)
wasm_runtime_free(data_list[i]->bytes);
/* Free the data segment structure itself */
if (data_list[i])
wasm_runtime_free(data_list[i]);
}
/* Free the array of data segment pointers */
wasm_runtime_free(data_list);
}
@ -1005,22 +982,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
InitializerExpression *expr, char *error_buf,
uint32 error_buf_size);
/**
* Load memory initialization data segments from the AOT module.
*
* This function reads memory initialization data segments from the buffer and
* creates AOTMemInitData structures for each segment. The data can either be
* cloned into new memory or referenced directly from the buffer.
*
* @param p_buf pointer to buffer containing memory init data
* @param buf_end end of buffer
* @param module the AOT module being loaded
* @param error_buf buffer for error messages
* @param error_buf_size size of error buffer
*
* @return true if successful, false if error occurred
*/
static bool
load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
AOTModule *module, char *error_buf,
@ -1052,8 +1013,8 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
return false;
}
read_uint32(buf, buf_end, byte_count);
if (!(data_list[i] = loader_malloc(sizeof(AOTMemInitData), error_buf,
error_buf_size))) {
size = offsetof(AOTMemInitData, bytes) + (uint64)byte_count;
if (!(data_list[i] = loader_malloc(size, error_buf, error_buf_size))) {
return false;
}
@ -1065,22 +1026,8 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
data_list[i]->offset.init_expr_type = init_value.init_expr_type;
data_list[i]->offset.u = init_value.u;
data_list[i]->byte_count = byte_count;
data_list[i]->bytes = NULL;
/* If the module owns the binary data, clone the bytes buffer */
if (module->is_binary_freeable) {
if (byte_count > 0) {
if (!(data_list[i]->bytes = loader_malloc(byte_count, error_buf,
error_buf_size))) {
return false;
}
read_byte_array(buf, buf_end, data_list[i]->bytes,
data_list[i]->byte_count);
}
}
else {
data_list[i]->bytes = (uint8 *)buf;
buf += byte_count;
}
read_byte_array(buf, buf_end, data_list[i]->bytes,
data_list[i]->byte_count);
}
*p_buf = buf;
@ -1089,21 +1036,6 @@ fail:
return false;
}
/**
* Load memory information from the AOT module.
*
* This function reads memory-related data including import memory count,
* memory count, memory flags, page sizes, and memory initialization data.
*
* @param p_buf pointer to buffer containing memory info
* @param buf_end end of buffer
* @param module the AOT module being loaded
* @param error_buf buffer for error messages
* @param error_buf_size size of error buffer
*
* @return true if successful, false if error occurred
*/
static bool
load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
char *error_buf, uint32 error_buf_size)
@ -1113,6 +1045,9 @@ 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;
@ -1255,7 +1190,6 @@ 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) {
@ -1309,13 +1243,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
read_uint32(buf, buf_end, type_idx);
read_uint32(buf, buf_end, length);
if (type_idx >= module->type_count
|| !wasm_type_is_array_type(module->types[type_idx])) {
set_error_buf(error_buf, error_buf_size,
"invalid or non-array type index.");
goto fail;
}
if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
expr->u.array_new_default.type_index = type_idx;
expr->u.array_new_default.length = length;
@ -1722,7 +1649,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, reuse it */
/* If there is an equivalence type, re-use it */
if (is_equivalence_type) {
uint8 u8;
/* padding */
@ -3196,12 +3123,10 @@ 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, ".srodata")
|| !strcmp(symbol, ".rdata")
|| !strcmp(symbol, ".rodata")
/* ".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)
@ -3330,7 +3255,7 @@ do_data_relocation(AOTModule *module, AOTRelocationGroup *group,
uint8 *data_addr;
uint32 data_size = 0, i;
AOTRelocation *relocation = group->relocations;
void *symbol_addr = NULL;
void *symbol_addr;
char *symbol, *data_section_name;
if (!strncmp(group->section_name, ".rela.", 6)) {
@ -4134,18 +4059,6 @@ 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:
@ -4429,13 +4342,6 @@ 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;
}
@ -4450,7 +4356,7 @@ aot_unload(AOTModule *module)
wasm_runtime_free(module->memories);
if (module->mem_init_data_list)
destroy_mem_init_data_list(module, module->mem_init_data_list,
destroy_mem_init_data_list(module->mem_init_data_list,
module->mem_init_data_count);
if (module->native_symbol_list)

View File

@ -7,6 +7,7 @@
#include "bh_log.h"
#include "bh_platform.h"
#if WASM_ENABLE_LINUX_PERF != 0
struct func_info {
uint32 idx;
void *ptr;
@ -31,15 +32,8 @@ get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs,
static int
compare_func_ptrs(const void *f1, const void *f2)
{
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;
return (intptr_t)((struct func_info *)f1)->ptr
- (intptr_t)((struct func_info *)f2)->ptr;
}
static struct func_info *
@ -52,8 +46,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) {
(void)snprintf(error_buf, error_buf_size,
"allocate memory failed when creating perf map");
snprintf(error_buf, error_buf_size,
"allocate memory failed when creating perf map");
return NULL;
}
@ -84,8 +78,7 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
if (!sorted_func_ptrs)
goto quit;
(void)snprintf(perf_map_path, sizeof(perf_map_path) - 1, "/tmp/perf-%d.map",
pid);
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,
@ -96,23 +89,19 @@ 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) {
(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);
}
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);
/* fwrite() is thread safe */
(void)fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map);
fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map);
}
LOG_VERBOSE("write map information from %s into /tmp/perf-%d.map",
@ -124,7 +113,8 @@ quit:
wasm_runtime_free(sorted_func_ptrs);
if (perf_map)
(void)fclose(perf_map);
fclose(perf_map);
return ret;
}
#endif /* WASM_ENABLE_LINUX_PERF != 0 */

View File

@ -122,10 +122,6 @@ 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), \

View File

@ -2315,6 +2315,13 @@ 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");
@ -2333,13 +2340,6 @@ 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) {
@ -2630,7 +2630,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
ret = invoke_native_internal(exec_env, func_ptr, func_type, NULL,
attachment, argv, argc, argv);
if (!ret) {
if (aot_copy_exception(module_inst, NULL)) {
#ifdef AOT_STACK_FRAME_DEBUG
if (aot_stack_frame_callback) {
aot_stack_frame_callback(exec_env);
@ -2651,7 +2651,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
aot_free_frame(exec_env);
#endif
return ret;
return ret && !aot_copy_exception(module_inst, NULL) ? true : false;
}
}
@ -3285,25 +3285,8 @@ 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);
@ -3344,25 +3327,8 @@ 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;
@ -4137,136 +4103,6 @@ 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)
@ -4877,8 +4713,8 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
}
prof_header.magic = 0xFF6C70726F667281LL;
/* Version 9 */
prof_header.version = 0x0000000000000009LL;
/* Version 8 */
prof_header.version = 0x0000000000000008LL;
/* with VARIANT_MASK_IR_PROF (IR Instrumentation) */
prof_header.version |= 0x1ULL << 56;
/* with VARIANT_MASK_MEMPROF (Memory Profile) */
@ -4887,19 +4723,14 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
prof_header.num_prof_counters = num_prof_counters;
prof_header.names_size = prof_names_size;
prof_header.value_kind_last = 1;
/* __llvm_prf_bits won't be used in PGO, set dummy value here */
prof_header.num_prof_bitmaps = 0;
prof_header.bitmap_delta = 0;
if (!is_little_endian()) {
aot_exchange_uint64((uint8 *)&prof_header.magic);
aot_exchange_uint64((uint8 *)&prof_header.version);
aot_exchange_uint64((uint8 *)&prof_header.num_prof_data);
aot_exchange_uint64((uint8 *)&prof_header.num_prof_counters);
aot_exchange_uint64((uint8 *)&prof_header.num_prof_bitmaps);
aot_exchange_uint64((uint8 *)&prof_header.names_size);
aot_exchange_uint64((uint8 *)&prof_header.counters_delta);
aot_exchange_uint64((uint8 *)&prof_header.bitmap_delta);
aot_exchange_uint64((uint8 *)&prof_header.value_kind_last);
}
@ -4917,23 +4748,19 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
prof_data_64->func_md5 = prof_data->func_md5;
prof_data_64->func_hash = prof_data->func_hash;
prof_data_64->offset_counters = prof_data->offset_counters;
prof_data_64->offset_bitmaps = prof_data->offset_bitmaps;
prof_data_64->func_ptr = prof_data->func_ptr;
prof_data_64->values = (uint64)(uintptr_t)prof_data->values;
prof_data_64->num_counters = prof_data->num_counters;
/* __llvm_prf_bits won't be used in PGO, set dummy value here */
prof_data_64->num_bitmaps = 0;
prof_data_64->num_value_sites[0] = prof_data->num_value_sites[0];
prof_data_64->num_value_sites[1] = prof_data->num_value_sites[1];
if (!is_little_endian()) {
aot_exchange_uint64((uint8 *)&prof_data_64->func_hash);
aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters);
aot_exchange_uint64((uint8 *)&prof_data_64->offset_bitmaps);
aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters);
aot_exchange_uint64((uint8 *)&prof_data_64->func_ptr);
aot_exchange_uint64((uint8 *)&prof_data_64->values);
aot_exchange_uint32((uint8 *)&prof_data_64->num_counters);
aot_exchange_uint32((uint8 *)&prof_data_64->num_bitmaps);
aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[0]);
aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[1]);
}

View File

@ -437,9 +437,6 @@ typedef struct AOTFrame {
} AOTFrame;
#if WASM_ENABLE_STATIC_PGO != 0
/* The bitmaps fields in LLVMProfileRawHeader, LLVMProfileData,
* LLVMProfileData_64 all dummy fields, it's used in MC/DC code coverage
* instead of PGO. See https://llvm.org/docs/InstrProfileFormat.html#bitmap */
typedef struct LLVMProfileRawHeader {
uint64 magic;
uint64 version;
@ -448,11 +445,8 @@ typedef struct LLVMProfileRawHeader {
uint64 padding_bytes_before_counters;
uint64 num_prof_counters;
uint64 padding_bytes_after_counters;
uint64 num_prof_bitmaps;
uint64 padding_bytes_after_bitmaps;
uint64 names_size;
uint64 counters_delta;
uint64 bitmap_delta;
uint64 names_delta;
uint64 value_kind_last;
} LLVMProfileRawHeader;
@ -470,12 +464,10 @@ typedef struct LLVMProfileData {
uint64 func_md5;
uint64 func_hash;
uint64 offset_counters;
uint64 offset_bitmaps;
uintptr_t func_ptr;
ValueProfNode **values;
uint32 num_counters;
uint16 num_value_sites[2];
uint32 num_bitmaps;
} LLVMProfileData;
/* The profiling data for writing to the output file, the width of
@ -485,12 +477,10 @@ typedef struct LLVMProfileData_64 {
uint64 func_md5;
uint64 func_hash;
uint64 offset_counters;
uint64 offset_bitmaps;
uint64 func_ptr;
uint64 values;
uint32 num_counters;
uint16 num_value_sites[2];
uint32 num_bitmaps;
} LLVMProfileData_64;
#endif /* end of WASM_ENABLE_STATIC_PGO != 0 */
@ -787,13 +777,6 @@ 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
*

View File

@ -1,45 +0,0 @@
/*
* 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;
}

View File

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

View File

@ -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 = 10; /* sizeof("aarch64v8"); */
s_size = 9; /* strlen("aarch64v8"); */
}
if (target_buf_size < s_size) {
s_size = target_buf_size;

View File

@ -1,39 +0,0 @@
/*
* 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();
}

View File

@ -30,39 +30,36 @@ void __umoddi3();
#pragma function(floor)
#pragma function(ceil)
static int64 __stdcall __divdi3(int64 a, int64 b)
static int64
__divdi3(int64 a, int64 b)
{
return a / b;
}
static uint64 __stdcall __udivdi3(uint64 a, uint64 b)
static uint64
__udivdi3(uint64 a, uint64 b)
{
return a / b;
}
static int64 __stdcall __moddi3(int64 a, int64 b)
static int64
__moddi3(int64 a, int64 b)
{
return a % b;
}
static uint64 __stdcall __umoddi3(uint64 a, uint64 b)
static uint64
__umoddi3(uint64 a, uint64 b)
{
return a % b;
}
#endif
static uint64 __stdcall __aulldiv(uint64 a, uint64 b)
static uint64
__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[] = {
@ -72,11 +69,7 @@ static SymbolMap target_sym_map[] = {
REG_SYM(__udivdi3),
REG_SYM(__moddi3),
REG_SYM(__umoddi3),
#if defined(_WIN32) || defined(_WIN32_)
REG_SYM(__aulldiv),
REG_SYM(__alldiv),
REG_SYM(__allrem)
#endif /* defined(_WIN32) || defined(_WIN32_) */
REG_SYM(__aulldiv)
};
/* clang-format on */

View File

@ -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
* address.
* addreess.
*/
static void
put_imm16_to_addr(int16 imm16, int16 *addr)

View File

@ -1,37 +1,15 @@
# 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})
list (APPEND c_source_all
${IWASM_AOT_DIR}/aot_intrinsic.c
${IWASM_AOT_DIR}/aot_loader.c
${IWASM_AOT_DIR}/aot_runtime.c
)
file (GLOB c_source_all ${IWASM_AOT_DIR}/*.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_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")
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c)
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_32.c)

View File

@ -45,7 +45,7 @@ _invokeNative:
/* Now x20 points to stack args */
/* Directly call the function if no args in stack */
/* Directly call the fucntion 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 function*/
mov sp, x22 /* restore sp which is saved before calling fuction*/
return:
mov x30, x20 /* restore x30(lr) */

View File

@ -43,7 +43,7 @@ _invokeNative:
/* Now x20 points to stack args */
/* Directly call the function if no args in stack */
/* Directly call the fucntion 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 function*/
mov sp, x22 /* restore sp which is saved before calling fuction*/
return:
mov x30, x20 /* restore x30(lr) */

View File

@ -53,7 +53,7 @@ _invokeNative:
vldr s13, [r4, #52]
vldr s14, [r4, #56]
vldr s15, [r4, #60]
/* Directly call the function if no args in stack */
/* Directly call the fucntion if no args in stack */
cmp r5, #0
beq call_func

View File

@ -4,7 +4,7 @@
*/
/*
* The float abi macros used below are from risc-v c api:
* The float abi macros used bellow 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 reserved stack, sp[j] = t5 */
RV_OP_STOREREG t5, 0(t4) /* store t5 to reseved 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 pointer to fp register */
RV_OP_LOADREG fp, 0 * RV_REG_SIZE(sp) /* load previous frame poniter 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

View File

@ -55,7 +55,7 @@ _invokeNative:
vldr s13, [r4, #52]
vldr s14, [r4, #56]
vldr s15, [r4, #60]
/* Directly call the function if no args in stack */
/* Directly call the fucntion if no args in stack */
cmp r5, #0
beq call_func

View File

@ -1145,14 +1145,6 @@ 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 don't care whether type2 is nullable or not. So
// we normalize it into its related one-byte type.
if (type2 == REF_TYPE_HT_NULLABLE
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
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;
@ -1196,15 +1188,19 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
}
#endif
else if (heap_type == HEAP_TYPE_NONE) {
return wasm_is_reftype_supers_of_none(type2, NULL, types,
type_count);
/* (ref none) */
/* TODO */
bh_assert(0);
}
else if (heap_type == HEAP_TYPE_NOEXTERN) {
return wasm_is_reftype_supers_of_noextern(type2);
/* (ref noextern) */
/* TODO */
bh_assert(0);
}
else if (heap_type == HEAP_TYPE_NOFUNC) {
return wasm_is_reftype_supers_of_nofunc(type2, NULL, types,
type_count);
/* (ref nofunc) */
/* TODO */
bh_assert(0);
}
else {
bh_assert(0);

View File

@ -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 environment and then calls
which initializes the wasi envrionment 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))) {
@ -289,7 +289,6 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
if (exec_env) {
wasm_runtime_dump_mem_consumption(exec_env);
(WASMModuleInstance *)module_inst->cur_exception
}
#endif
@ -713,10 +712,7 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
}
case VALUE_TYPE_F32:
{
// Explicit cast to double to avoid warning.
// Float arguments are promoted to double in variadic
// functions per section 6.5.2.2 of the C99 standard.
os_printf("%.7g:f32", (double)*(float32 *)(argv1 + k));
os_printf("%.7g:f32", *(float32 *)(argv1 + k));
k++;
break;
}

View File

@ -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 compatible with the
/* whether the combination of compilation flags are compatable with the
* package type */
{
PackageType pkg_type;

View File

@ -85,10 +85,6 @@ 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
@ -206,7 +202,7 @@ wasm_exec_env_destroy(WASMExecEnv *exec_env)
wasm_cluster_wait_for_all_except_self(cluster, exec_env);
#if WASM_ENABLE_DEBUG_INTERP != 0
/* Must fire exit event after other threads exits, otherwise
the stopped thread will be overridden by other threads */
the stopped thread will be overriden by other threads */
wasm_cluster_thread_exited(exec_env);
#endif
/* We have waited for other threads, this is the only alive thread, so
@ -280,6 +276,8 @@ 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
@ -288,11 +286,9 @@ 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 {
uint8 *stack_boundary = os_thread_get_stack_boundary();
else
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);

View File

@ -87,11 +87,6 @@ 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

View File

@ -151,13 +151,11 @@ 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) \
&& (WASM_ENABLE_SIMDE == 0)
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)
/*
* 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
* Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have
* SIMD implemented. It's safer to reject v128, especially for the
* fast interpreter.
*/
if (value_type == VALUE_TYPE_V128)
return false;

View File

@ -1253,14 +1253,6 @@ 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);
}
@ -1375,7 +1367,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
if (!(memory_data_new =
realloc_func(Alloc_For_LinearMemory, full_size_mmaped,
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
allocator_user_data,
NULL,
#endif
memory_data_old, total_size_new))) {
ret = false;
@ -1397,7 +1389,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
if (full_size_mmaped) {
#ifdef BH_PLATFORM_WINDOWS
if (!os_mem_commit(memory->memory_data_end,
total_size_new - total_size_old,
(mem_offset_t)(total_size_new - total_size_old),
MMAP_PROT_READ | MMAP_PROT_WRITE)) {
ret = false;
goto return_func;
@ -1405,12 +1397,12 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
#endif
if (os_mprotect(memory->memory_data_end,
total_size_new - total_size_old,
(mem_offset_t)(total_size_new - total_size_old),
MMAP_PROT_READ | MMAP_PROT_WRITE)
!= 0) {
#ifdef BH_PLATFORM_WINDOWS
os_mem_decommit(memory->memory_data_end,
total_size_new - total_size_old);
(mem_offset_t)(total_size_new - total_size_old));
#endif
ret = false;
goto return_func;
@ -1688,7 +1680,7 @@ wasm_deallocate_linear_memory(WASMMemoryInstance *memory_inst)
(void)map_size;
free_func(Alloc_For_LinearMemory,
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
allocator_user_data,
NULL,
#endif
memory_inst->memory_data);
#else
@ -1741,7 +1733,7 @@ wasm_allocate_linear_memory(uint8 **data, bool is_shared_memory,
(void)wasm_mmap_linear_memory;
if (!(*data = malloc_func(Alloc_For_LinearMemory,
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
allocator_user_data,
NULL,
#endif
*memory_data_size))) {
return BHT_ERROR;

View File

@ -757,10 +757,7 @@ wasm_runtime_full_init_internal(RuntimeInitArgs *init_args)
#endif
#if WASM_ENABLE_GC != 0
uint32 gc_heap_size = init_args->gc_heap_size;
if (gc_heap_size > 0) {
gc_heap_size_default = gc_heap_size;
}
gc_heap_size_default = init_args->gc_heap_size;
#endif
#if WASM_ENABLE_JIT != 0
@ -1504,7 +1501,7 @@ wasm_runtime_load_ex(uint8 *buf, uint32 size, const LoadArgs *args,
error_buf_size);
}
bool
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_resolve_symbols(WASMModuleCommon *module)
{
#if WASM_ENABLE_INTERP != 0
@ -1743,45 +1740,6 @@ 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)
{
@ -2285,15 +2243,6 @@ 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)
@ -3065,9 +3014,9 @@ static const char *exception_msgs[] = {
"wasm operand stack overflow", /* EXCE_OPERAND_STACK_OVERFLOW */
"failed to compile fast jit function", /* EXCE_FAILED_TO_COMPILE_FAST_JIT_FUNC */
/* GC related exceptions */
"null function reference", /* EXCE_NULL_FUNC_OBJ */
"null structure reference", /* EXCE_NULL_STRUCT_OBJ */
"null array reference", /* EXCE_NULL_ARRAY_OBJ */
"null function object", /* EXCE_NULL_FUNC_OBJ */
"null structure object", /* EXCE_NULL_STRUCT_OBJ */
"null array reference", /* EXCE_NULL_ARRAY_OBJ */
"null i31 reference", /* EXCE_NULL_I31_OBJ */
"null reference", /* EXCE_NULL_REFERENCE */
"create rtt type failed", /* EXCE_FAILED_TO_CREATE_RTT_TYPE */
@ -3075,7 +3024,7 @@ static const char *exception_msgs[] = {
"create array object failed", /* EXCE_FAILED_TO_CREATE_ARRAY_OBJ */
"create externref object failed", /* EXCE_FAILED_TO_CREATE_EXTERNREF_OBJ */
"cast failure", /* EXCE_CAST_FAILURE */
"out of bounds array access", /* EXCE_ARRAY_IDX_OOB */
"out of bounds array access", /* EXCE_ARRAY_IDX_OOB */
/* stringref related exceptions */
"create string object failed", /* EXCE_FAILED_TO_CREATE_STRING */
"create stringref failed", /* EXCE_FAILED_TO_CREATE_STRINGREF */
@ -3886,15 +3835,11 @@ 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 != 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;
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;
if (dir_count > 0) {
init_options.preopenc = dir_count;
@ -4321,68 +4266,31 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
export_type->kind = aot_export->kind;
switch (export_type->kind) {
case WASM_IMPORT_EXPORT_KIND_FUNC:
{
if (aot_export->index < aot_module->import_func_count) {
export_type->u.func_type =
(AOTFuncType *)aot_module
->import_funcs[aot_export->index]
.func_type;
}
else {
export_type->u.func_type =
(AOTFuncType *)aot_module
->types[aot_module->func_type_indexes
[aot_export->index
- aot_module->import_func_count]];
}
export_type->u.func_type =
(AOTFuncType *)aot_module
->types[aot_module->func_type_indexes
[aot_export->index
- aot_module->import_func_count]];
break;
}
case WASM_IMPORT_EXPORT_KIND_GLOBAL:
{
if (aot_export->index < aot_module->import_global_count) {
export_type->u.global_type =
&aot_module->import_globals[aot_export->index].type;
}
else {
export_type->u.global_type =
&aot_module
->globals[aot_export->index
- aot_module->import_global_count]
.type;
}
export_type->u.global_type =
&aot_module
->globals[aot_export->index
- aot_module->import_global_count]
.type;
break;
}
case WASM_IMPORT_EXPORT_KIND_TABLE:
{
if (aot_export->index < aot_module->import_table_count) {
export_type->u.table_type =
&aot_module->import_tables[aot_export->index]
.table_type;
}
else {
export_type->u.table_type =
&aot_module
->tables[aot_export->index
- aot_module->import_table_count]
.table_type;
}
export_type->u.table_type =
&aot_module
->tables[aot_export->index
- aot_module->import_table_count]
.table_type;
break;
}
case WASM_IMPORT_EXPORT_KIND_MEMORY:
{
if (aot_export->index < aot_module->import_memory_count) {
export_type->u.memory_type =
&aot_module->import_memories[aot_export->index]
.mem_type;
}
else {
export_type->u.memory_type =
&aot_module
->memories[aot_export->index
- aot_module->import_memory_count];
}
export_type->u.memory_type =
&aot_module->memories[aot_export->index
- aot_module->import_memory_count];
break;
}
default:
bh_assert(0);
break;
@ -4404,76 +4312,31 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
export_type->kind = wasm_export->kind;
switch (export_type->kind) {
case WASM_IMPORT_EXPORT_KIND_FUNC:
{
if (wasm_export->index < wasm_module->import_function_count) {
export_type->u.func_type =
(WASMFuncType *)wasm_module
->import_functions[wasm_export->index]
.u.function.func_type;
}
else {
export_type->u.func_type =
wasm_module
->functions[wasm_export->index
- wasm_module->import_function_count]
->func_type;
}
export_type->u.func_type =
wasm_module
->functions[wasm_export->index
- wasm_module->import_function_count]
->func_type;
break;
}
case WASM_IMPORT_EXPORT_KIND_GLOBAL:
{
if (wasm_export->index < wasm_module->import_global_count) {
export_type->u.global_type =
(WASMGlobalType *)&wasm_module
->import_globals[wasm_export->index]
.u.global.type;
}
else {
export_type->u.global_type =
&wasm_module
->globals[wasm_export->index
- wasm_module->import_global_count]
.type;
}
export_type->u.global_type =
&wasm_module
->globals[wasm_export->index
- wasm_module->import_global_count]
.type;
break;
}
case WASM_IMPORT_EXPORT_KIND_TABLE:
{
if (wasm_export->index < wasm_module->import_table_count) {
export_type->u.table_type =
(WASMTableType *)&wasm_module
->import_tables[wasm_export->index]
.u.table.table_type;
}
else {
export_type->u.table_type =
&wasm_module
->tables[wasm_export->index
- wasm_module->import_table_count]
.table_type;
}
export_type->u.table_type =
&wasm_module
->tables[wasm_export->index
- wasm_module->import_table_count]
.table_type;
break;
}
case WASM_IMPORT_EXPORT_KIND_MEMORY:
{
if (wasm_export->index < wasm_module->import_memory_count) {
export_type->u.memory_type =
(WASMMemoryType *)&wasm_module
->import_memories[wasm_export->index]
.u.memory.mem_type;
}
else {
export_type->u.memory_type =
&wasm_module
->memories[wasm_export->index
- wasm_module->import_memory_count];
}
export_type->u.memory_type =
&wasm_module->memories[wasm_export->index
- wasm_module->import_memory_count];
break;
}
default:
bh_assert(0);
break;
@ -4513,9 +4376,8 @@ 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_EXTERNREF:
case VALUE_TYPE_VOID:
default:
{
@ -7849,7 +7711,7 @@ wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env,
return true;
}
bool
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module)
{
#if WASM_ENABLE_INTERP != 0

View File

@ -37,10 +37,6 @@ 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); \
@ -53,7 +49,6 @@ 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
@ -73,12 +68,6 @@ 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))
@ -86,7 +75,6 @@ STORE_V128(void *addr, V128 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 { \
@ -95,15 +83,6 @@ STORE_V128(void *addr, V128 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); \
@ -145,17 +124,6 @@ STORE_V128(void *addr, V128 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)
{
@ -271,94 +239,7 @@ 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)
{
@ -583,6 +464,19 @@ 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;
@ -758,13 +652,6 @@ 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);
@ -791,17 +678,9 @@ WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_native_stack_boundary(WASMExecEnv *exec_env,
uint8 *native_stack_boundary);
#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_API_EXTERN void
wasm_runtime_set_bounds_checks(WASMModuleInstanceCommon *module_inst,
bool enable);

View File

@ -36,11 +36,8 @@ aot_destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count)
{
uint32 i;
for (i = 0; i < count; i++)
if (data_list[i]) {
if (data_list[i]->bytes)
wasm_runtime_free(data_list[i]->bytes);
if (data_list[i])
wasm_runtime_free(data_list[i]);
}
wasm_runtime_free(data_list);
}
@ -63,7 +60,8 @@ aot_create_mem_init_data_list(const WASMModule *module)
/* Create each memory data segment */
for (i = 0; i < module->data_seg_count; i++) {
size = sizeof(AOTMemInitData);
size = offsetof(AOTMemInitData, bytes)
+ (uint64)module->data_segments[i]->data_length;
if (size >= UINT32_MAX
|| !(data_list[i] = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
@ -71,31 +69,18 @@ aot_create_mem_init_data_list(const WASMModule *module)
}
#if WASM_ENABLE_BULK_MEMORY != 0
/* Set bulk memory specific properties if enabled */
data_list[i]->is_passive = module->data_segments[i]->is_passive;
data_list[i]->memory_index = module->data_segments[i]->memory_index;
#endif
data_list[i]->offset = module->data_segments[i]->base_offset;
data_list[i]->byte_count = module->data_segments[i]->data_length;
data_list[i]->bytes = NULL;
/* Allocate memory for AOT compiler is OK, because the data segment
* is small and the host memory is enough */
if (data_list[i]->byte_count > 0) {
data_list[i]->bytes = wasm_runtime_malloc(data_list[i]->byte_count);
if (!data_list[i]->bytes) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
/* Copy the actual data bytes from the WASM module */
memcpy(data_list[i]->bytes, module->data_segments[i]->data,
module->data_segments[i]->data_length);
}
memcpy(data_list[i]->bytes, module->data_segments[i]->data,
module->data_segments[i]->data_length);
}
return data_list;
fail:
/* Clean up allocated memory in case of failure */
aot_destroy_mem_init_data_list(data_list, module->data_seg_count);
return NULL;
}
@ -502,70 +487,60 @@ calculate_struct_field_sizes_offsets(AOTCompData *comp_data, bool is_target_x86,
}
#endif
/**
* Checks if target architecture is 64-bit based on target_arch string.
*
* @param target_arch The target architecture string (e.g. "x86_64", "aarch64")
* @return true if target is 64-bit architecture, false otherwise
*
* If target_arch is NULL, detection is based on UINTPTR_MAX.
* Otherwise looks for "64" in target_arch string.
*/
static bool
arch_is_64bit(const char *target_arch)
AOTCompData *
aot_create_comp_data(WASMModule *module, const char *target_arch,
bool gc_enabled)
{
if (!target_arch) {
#if UINTPTR_MAX == UINT64_MAX
return true;
#else
return false;
AOTCompData *comp_data;
uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0, i, j;
uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0;
uint64 size;
bool is_64bit_target = false;
#if WASM_ENABLE_GC != 0
bool is_target_x86 = false;
#endif
}
/* All 64bit targets contains "64" string in their target name */
return strstr(target_arch, "64") != NULL;
}
/**
* Checks if target architecture is x86/x64 based on target_arch string.
*
* @param target_arch The target architecture string (e.g. "x86_64", "i386")
* @return true if target is x86/x64 architecture, false otherwise
*
* If target_arch is NULL, detection is based on build-time definitions.
* Otherwise checks for x86_64 or i386 in target_arch string.
*/
static bool
arch_is_x86(const char *target_arch)
{
#if WASM_ENABLE_GC != 0
if (!target_arch) {
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_X86_32)
return true;
#else
return false;
is_target_x86 = true;
#endif
}
return !strncmp(target_arch, "x86_64", 6)
|| !strncmp(target_arch, "i386", 4);
}
else {
if (!strncmp(target_arch, "x86_64", 6)
|| !strncmp(target_arch, "i386", 4))
is_target_x86 = true;
}
#endif
/**
* Initialize memory information in AOT compilation data from WASM module.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing memory information
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_memories(AOTCompData *comp_data, WASMModule *module)
{
uint32 i, j;
uint64 size;
if (!target_arch) {
#if UINTPTR_MAX == UINT64_MAX
is_64bit_target = true;
#endif
}
else {
/* All 64bit targets contains "64" string in their target name */
if (strstr(target_arch, "64") != NULL) {
is_64bit_target = true;
}
}
/* Allocate memory */
if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) {
aot_set_last_error("create compile data failed.\n");
return NULL;
}
memset(comp_data, 0, sizeof(AOTCompData));
comp_data->memory_count =
module->import_memory_count + module->memory_count;
/* TODO: create import memories */
/* Allocate memory for memory array, reserve one AOTMemory space at least */
/* TODO: multi-memory */
if (!comp_data->memory_count)
comp_data->memory_count = 1;
@ -573,7 +548,7 @@ aot_init_memories(AOTCompData *comp_data, WASMModule *module)
if (size >= UINT32_MAX
|| !(comp_data->memories = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("create memories array failed.\n");
return false;
goto fail;
}
memset(comp_data->memories, 0, size);
@ -605,30 +580,22 @@ aot_init_memories(AOTCompData *comp_data, WASMModule *module)
}
}
return true;
}
/**
* Initialize table information in AOT compilation data from WASM module.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing table information
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_tables(AOTCompData *comp_data, WASMModule *module)
{
uint32 i, j;
uint64 size;
/* Create memory data segments */
comp_data->mem_init_data_count = module->data_seg_count;
if (comp_data->mem_init_data_count > 0
&& !(comp_data->mem_init_data_list =
aot_create_mem_init_data_list(module)))
goto fail;
/* Create tables */
comp_data->table_count = module->import_table_count + module->table_count;
if (comp_data->table_count > 0) {
size = sizeof(AOTTable) * (uint64)comp_data->table_count;
if (size >= UINT32_MAX
|| !(comp_data->tables = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("create tables array failed.\n");
return false;
aot_set_last_error("create memories array failed.\n");
goto fail;
}
memset(comp_data->tables, 0, size);
for (i = 0; i < comp_data->table_count; i++) {
@ -674,150 +641,64 @@ aot_init_tables(AOTCompData *comp_data, WASMModule *module)
}
}
return true;
}
/**
* Initialize memory segment information in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing memory segments
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_memory_segments(AOTCompData *comp_data, WASMModule *module)
{
comp_data->mem_init_data_count = module->data_seg_count;
if (comp_data->mem_init_data_count > 0
&& !(comp_data->mem_init_data_list =
aot_create_mem_init_data_list(module))) {
return false;
}
return true;
}
/**
* Initialize table segment information in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing table segments
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_table_segments(AOTCompData *comp_data, WASMModule *module)
{
/* Create table data segments */
comp_data->table_init_data_count = module->table_seg_count;
if (comp_data->table_init_data_count > 0
&& !(comp_data->table_init_data_list =
aot_create_table_init_data_list(module))) {
return false;
}
return true;
}
aot_create_table_init_data_list(module)))
goto fail;
/**
* Initialize global variable information in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing global information
* @param gc_enabled whether garbage collection is enabled
* @param import_global_data_size_64bit [out] size of imported global data for
* 64-bit
* @param import_global_data_size_32bit [out] size of imported global data for
* 32-bit
* @param global_data_size_64bit [out] size of global data for 64-bit
* @param global_data_size_32bit [out] size of global data for 32-bit
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_globals(AOTCompData *comp_data, WASMModule *module, bool gc_enabled,
uint32 *import_global_data_size_64bit,
uint32 *import_global_data_size_32bit,
uint32 *global_data_size_64bit, uint32 *global_data_size_32bit)
{
/* Create import globals */
comp_data->import_global_count = module->import_global_count;
if (comp_data->import_global_count > 0
&& !(comp_data->import_globals = aot_create_import_globals(
module, gc_enabled, import_global_data_size_64bit,
import_global_data_size_32bit))) {
return false;
}
module, gc_enabled, &import_global_data_size_64bit,
&import_global_data_size_32bit)))
goto fail;
/* Create globals */
comp_data->global_count = module->global_count;
if (comp_data->global_count
&& !(comp_data->globals = aot_create_globals(
module, gc_enabled, *import_global_data_size_64bit,
*import_global_data_size_32bit, global_data_size_64bit,
global_data_size_32bit))) {
return false;
}
module, gc_enabled, import_global_data_size_64bit,
import_global_data_size_32bit, &global_data_size_64bit,
&global_data_size_32bit)))
goto fail;
comp_data->global_data_size_64bit =
*import_global_data_size_64bit + *global_data_size_64bit;
import_global_data_size_64bit + global_data_size_64bit;
comp_data->global_data_size_32bit =
*import_global_data_size_32bit + *global_data_size_32bit;
import_global_data_size_32bit + global_data_size_32bit;
return true;
}
/**
* Initialize type information in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing type information
* @param is_target_x86 whether the target architecture is x86
* @param gc_enabled whether garbage collection is enabled
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_types(AOTCompData *comp_data, WASMModule *module, bool is_target_x86,
bool gc_enabled)
{
/* Create types, they are checked by wasm loader */
comp_data->type_count = module->type_count;
comp_data->types = module->types;
#if WASM_ENABLE_GC != 0
/* Calculate the field sizes and field offsets for 64-bit and 32-bit
targets since they may vary in 32-bit target and 64-bit target */
calculate_struct_field_sizes_offsets(comp_data, is_target_x86, gc_enabled);
#endif
return true;
}
/**
* Initialize function information in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing function information
* @param is_64bit_target whether the target architecture is 64-bit
* @return true if initialization succeeded, false otherwise
*/
static bool
aot_init_functions(AOTCompData *comp_data, WASMModule *module,
bool is_64bit_target)
{
/* Create import functions */
comp_data->import_func_count = module->import_function_count;
if (comp_data->import_func_count
&& !(comp_data->import_funcs = aot_create_import_funcs(module))) {
return false;
}
&& !(comp_data->import_funcs = aot_create_import_funcs(module)))
goto fail;
/* Create functions */
comp_data->func_count = module->function_count;
if (comp_data->func_count
&& !(comp_data->funcs =
aot_create_funcs(module, is_64bit_target ? 8 : 4))) {
return false;
}
aot_create_funcs(module, is_64bit_target ? 8 : 4)))
goto fail;
return true;
}
#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0
/* Create custom name section */
comp_data->name_section_buf = module->name_section_buf;
comp_data->name_section_buf_end = module->name_section_buf_end;
#endif
/**
* Initialize auxiliary data in AOT compilation data.
*
* @param comp_data the AOT compilation data structure to initialize
* @param module the source WASM module containing auxiliary data
*/
static void
aot_init_aux_data(AOTCompData *comp_data, WASMModule *module)
{
/* Create aux data/heap/stack information */
comp_data->aux_data_end_global_index = module->aux_data_end_global_index;
comp_data->aux_data_end = module->aux_data_end;
comp_data->aux_heap_base_global_index = module->aux_heap_base_global_index;
@ -836,43 +717,6 @@ aot_init_aux_data(AOTCompData *comp_data, WASMModule *module)
comp_data->string_literal_ptrs_wp = module->string_literal_ptrs;
comp_data->string_literal_lengths_wp = module->string_literal_lengths;
#endif
}
AOTCompData *
aot_create_comp_data(WASMModule *module, const char *target_arch,
bool gc_enabled)
{
AOTCompData *comp_data;
uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0;
uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0;
bool is_64bit_target = arch_is_64bit(target_arch);
bool is_target_x86 = arch_is_x86(target_arch);
if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) {
aot_set_last_error("create compile data failed.\n");
return NULL;
}
memset(comp_data, 0, sizeof(AOTCompData));
if (!aot_init_memories(comp_data, module)
|| !aot_init_memory_segments(comp_data, module)
|| !aot_init_tables(comp_data, module)
|| !aot_init_table_segments(comp_data, module)
|| !aot_init_globals(comp_data, module, gc_enabled,
&import_global_data_size_64bit,
&import_global_data_size_32bit,
&global_data_size_64bit, &global_data_size_32bit)
|| !aot_init_types(comp_data, module, is_target_x86, gc_enabled)
|| !aot_init_functions(comp_data, module, is_64bit_target)) {
goto fail;
}
#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0
comp_data->name_section_buf = module->name_section_buf;
comp_data->name_section_buf_end = module->name_section_buf_end;
#endif
aot_init_aux_data(comp_data, module);
comp_data->wasm_module = module;

View File

@ -103,7 +103,7 @@ typedef struct AOTMemInitData {
/* Byte count */
uint32 byte_count;
/* Byte array */
uint8 *bytes;
uint8 bytes[1];
} AOTMemInitData;
/**

View File

@ -1316,13 +1316,6 @@ 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:
{

View File

@ -790,7 +790,7 @@ set_local_gc_ref(AOTCompFrame *frame, int n, LLVMValueRef value, uint8 ref_type)
} \
else { \
char *func_name = #name; \
/* AOT mode, declare the function */ \
/* AOT mode, delcare the function */ \
if (!(func = LLVMGetNamedFunction(func_ctx->module, func_name)) \
&& !(func = LLVMAddFunction(func_ctx->module, func_name, \
func_type))) { \

View File

@ -920,11 +920,9 @@ 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(name, AOT_FUNC_INTERNAL_PREFIX,
&& !strncmp(relocation->symbol_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 */
@ -1792,9 +1790,7 @@ 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);
if (init_datas[i]->byte_count) {
EMIT_BUF(init_datas[i]->bytes, 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)) {
@ -2491,8 +2487,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 */
const char *name = relocation->symbol_name;
if (str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)
if (str_starts_with(relocation->symbol_name,
AOT_FUNC_INTERNAL_PREFIX)
&& ((obj_data->target_info.bin_type
== 6 /* AOT_COFF64_BIN_TYPE */
&& relocation->relocation_type
@ -2502,7 +2498,8 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
&& relocation->relocation_type
== 20 /* IMAGE_REL_I386_REL32 */))) {
uint32 func_idx =
atoi(name + strlen(AOT_FUNC_INTERNAL_PREFIX));
atoi(relocation->symbol_name
+ strlen(AOT_FUNC_INTERNAL_PREFIX));
uint64 text_offset, reloc_offset, reloc_addend;
bh_assert(func_idx < obj_data->func_count);
@ -3053,27 +3050,6 @@ 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)
{
@ -3270,17 +3246,8 @@ 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")
@ -3378,12 +3345,6 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data)
bh_memcpy_s(data_section->name, size, buf, size);
data_section->is_name_allocated = true;
}
else if (obj_data->comp_ctx->enable_llvm_pgo
&& !strcmp(name, "__llvm_prf_bits")) {
LOG_WARNING("__llvm_prf_bits section is not supported and "
"shouldn't be used in PGO.");
return false;
}
if (obj_data->comp_ctx->enable_llvm_pgo
&& !strcmp(name, "__llvm_prf_names")) {
@ -3563,9 +3524,12 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
}
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
if ((name =
LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info))
&& (!strcmp(name, aot_stack_sizes_alias_name))) {
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 0 /* cf. https://github.com/llvm/llvm-project/issues/67765 */
uint64 sz = LLVMGetSymbolSize(sym_itr);
if (sz != sizeof(uint32) * obj_data->func_count
@ -3729,8 +3693,8 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
}
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
name = LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info);
if (name && str_starts_with(name, prefix)) {
if ((name = (char *)LLVMGetSymbolName(sym_itr))
&& str_starts_with(name, prefix)) {
/* symbol aot_func#n */
func_index = (uint32)atoi(name + strlen(prefix));
if (func_index < obj_data->func_count) {
@ -3768,7 +3732,8 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
}
}
}
else if (name && str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)) {
else if ((name = (char *)LLVMGetSymbolName(sym_itr))
&& 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) {
@ -3879,7 +3844,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
}
}
/* parse each relocation */
/* pares each relocation */
if (!(rel_itr = LLVMGetRelocations(rel_sec))) {
aot_set_last_error("llvm get relocations failed.");
return false;
@ -3916,8 +3881,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
/* set relocation fields */
relocation->relocation_type = (uint32)type;
relocation->symbol_name =
LLVMGetSymbolNameAndUnDecorate(rel_sym, obj_data->target_info);
relocation->symbol_name = (char *)LLVMGetSymbolName(rel_sym);
relocation->relocation_offset = offset;
if (!strcmp(group->section_name, ".rela.text.unlikely.")
|| !strcmp(group->section_name, ".rel.text.unlikely.")) {
@ -3944,7 +3908,12 @@ 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)) {
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))) {
/* discard const */
relocation->symbol_name = (char *)aot_stack_sizes_section_name;
}
@ -4013,21 +3982,8 @@ 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.")
#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
)) {
|| str_starts_with(relocation->symbol_name,
".Lswitch.table."))) {
/* change relocation->relocation_addend and
relocation->symbol_name */
LLVMSectionIteratorRef contain_section;

View File

@ -1218,28 +1218,6 @@ 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

View File

@ -347,8 +347,17 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
POP_F32(value);
if (comp_ctx->is_indirect_mode
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
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 {
WASMValue wasm_value;
if (sign) {
wasm_value.f32 = -2147483904.0f;
@ -367,16 +376,6 @@ 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);
@ -401,8 +400,17 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
POP_F64(value);
if (comp_ctx->is_indirect_mode
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
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 {
WASMValue wasm_value;
if (sign) {
wasm_value.f64 = -2147483649.0;
@ -421,16 +429,6 @@ 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);
@ -556,8 +554,17 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
POP_F32(value);
if (comp_ctx->is_indirect_mode
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
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 {
WASMValue wasm_value;
if (sign) {
wasm_value.f32 = -9223373136366403584.0f;
@ -576,16 +583,6 @@ 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);
@ -610,8 +607,17 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
POP_F64(value);
if (comp_ctx->is_indirect_mode
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
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 {
WASMValue wasm_value;
if (sign) {
wasm_value.f64 = -9223372036854777856.0;
@ -630,16 +636,6 @@ 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);

View File

@ -1832,7 +1832,6 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build load failed.");
goto fail;
}
LLVMSetAlignment(ext_ret, 4);
PUSH(ext_ret, ext_ret_types[i]);
}
}
@ -2069,7 +2068,6 @@ call_aot_call_indirect_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build load failed.");
return false;
}
LLVMSetAlignment(value_rets[i], 4);
cell_num += wasm_value_type_cell_num_internal(wasm_ret_types[i],
comp_ctx->pointer_size);
}
@ -2701,7 +2699,6 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build load failed.");
goto fail;
}
LLVMSetAlignment(ext_ret, 4);
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
}
}
@ -3133,7 +3130,6 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build load failed.");
goto fail;
}
LLVMSetAlignment(ext_ret, 4);
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
}
}
@ -3209,7 +3205,6 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build load failed.");
goto fail;
}
LLVMSetAlignment(ext_ret, 4);
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
}
}

View File

@ -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 accessed, (2) using
first byte of the shared heap won't be accesed, (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, declare the function */
/* AOT mode, delcare 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 address directly if constant offset and inside memory space */
/* return addres 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);

View File

@ -653,22 +653,15 @@ compile_int_sub(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
}
static LLVMValueRef
compile_int_mul(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef left, LLVMValueRef right, bool is_i32)
compile_int_mul(AOTCompContext *comp_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 */
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;
return LLVMBuildMul(comp_ctx->builder, left, right, "mul");
}
static bool
@ -686,9 +679,8 @@ 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, func_ctx, left, right, is_i32),
"compile int mul fail.");
DEF_INT_BINARY_OP(compile_int_mul(comp_ctx, left, right, is_i32),
"compile int mul fail.");
return true;
case INT_DIV_S:
case INT_DIV_U:
@ -734,57 +726,43 @@ fail:
}
static LLVMValueRef
compile_int_shl(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef left, LLVMValueRef right, bool is_i32)
compile_int_shl(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
bool is_i32)
{
LLVMValueRef res;
SHIFT_COUNT_MASK;
/* Build shl */
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);
LLVM_BUILD_OP(Shl, left, right, res, "shl", NULL);
return res;
}
static LLVMValueRef
compile_int_shr_s(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef left, LLVMValueRef right, bool is_i32)
compile_int_shr_s(AOTCompContext *comp_ctx, LLVMValueRef left,
LLVMValueRef right, bool is_i32)
{
LLVMValueRef res;
SHIFT_COUNT_MASK;
/* Build shl */
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);
LLVM_BUILD_OP(AShr, left, right, res, "shr_s", NULL);
return res;
}
static LLVMValueRef
compile_int_shr_u(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef left, LLVMValueRef right, bool is_i32)
compile_int_shr_u(AOTCompContext *comp_ctx, LLVMValueRef left,
LLVMValueRef right, bool is_i32)
{
LLVMValueRef res;
SHIFT_COUNT_MASK;
/* Build shl */
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);
LLVM_BUILD_OP(LShr, left, right, res, "shr_u", NULL);
return res;
}
@ -836,18 +814,16 @@ 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, func_ctx, left, right, is_i32), NULL);
DEF_INT_BINARY_OP(compile_int_shl(comp_ctx, left, right, is_i32),
NULL);
return true;
case INT_SHR_S:
DEF_INT_BINARY_OP(
compile_int_shr_s(comp_ctx, func_ctx, left, right, is_i32),
NULL);
DEF_INT_BINARY_OP(compile_int_shr_s(comp_ctx, left, right, is_i32),
NULL);
return true;
case INT_SHR_U:
DEF_INT_BINARY_OP(
compile_int_shr_u(comp_ctx, func_ctx, left, right, is_i32),
NULL);
DEF_INT_BINARY_OP(compile_int_shr_u(comp_ctx, left, right, is_i32),
NULL);
return true;
case INT_ROTL:
DEF_INT_BINARY_OP(

View File

@ -711,7 +711,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
prefix)))
goto fail;
if (comp_ctx->disable_llvm_jump_tables) {
if (comp_ctx->is_indirect_mode) {
/* avoid LUT relocations ("switch-table") */
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
comp_ctx->context, "no-jump-tables",
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
@ -1719,7 +1720,7 @@ aot_create_stack_sizes(const AOTCompData *comp_data, AOTCompContext *comp_ctx)
* This value is a placeholder, which will be replaced
* after the corresponding functions are compiled.
*
* Don't use zeros because LLVM can optimize them to
* Don't use zeros becasue LLVM can optimize them to
* zeroinitializer.
*/
values[i] = I32_NEG_ONE;
@ -2353,7 +2354,7 @@ create_target_machine_detect_host(AOTCompContext *comp_ctx)
}
if (!LLVMTargetHasJIT(target)) {
aot_set_last_error("unsupported JIT on this platform.");
aot_set_last_error("unspported JIT on this platform.");
goto fail;
}
@ -2520,8 +2521,7 @@ aot_compiler_init(void)
LLVMInitializeCore(LLVMGetGlobalPassRegistry());
#endif
/* fuzzing only use host targets for simple */
#if WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_FUZZ_TEST == 0
#if WASM_ENABLE_WAMR_COMPILER != 0
/* Init environment of all targets for AOT compiler */
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargets();
@ -2664,18 +2664,12 @@ 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;
@ -2742,23 +2736,10 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
}
else {
/* Create LLVM target machine */
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;
}
arch = option->target_arch;
abi = option->target_abi;
cpu = option->target_cpu;
features = option->cpu_features;
opt_level = option->opt_level;
size_level = option->size_level;
@ -2999,7 +2980,6 @@ 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 = "";
}
@ -3204,21 +3184,6 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
#if WASM_ENABLE_WAMR_COMPILER != 0
WASMModule *wasm_module = (WASMModule *)comp_data->wasm_module;
bool is_memory64 = false;
/* TODO: multi-memories for now assuming the memory64 flag of a memory is
* consistent across multi-memories */
if (wasm_module->import_memory_count > 0)
is_memory64 = !!(wasm_module->import_memories[0].u.memory.mem_type.flags
& MEMORY64_FLAG);
else if (wasm_module->memory_count > 0)
is_memory64 = !!(wasm_module->memories[0].flags & MEMORY64_FLAG);
if (!(option->bounds_checks == 1 || option->bounds_checks == 0)
&& is_memory64) {
/* For memory64, the boundary check default value is true */
comp_ctx->enable_bound_check = true;
}
/* Return error if SIMD is disabled by command line but SIMD instructions
* are used */
@ -3369,11 +3334,6 @@ 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);
@ -3447,7 +3407,7 @@ aot_get_native_symbol_index(AOTCompContext *comp_ctx, const char *symbol)
sym = bh_list_first_elem(&comp_ctx->native_symbols);
/* Lookup an existing symbol record */
/* Lookup an existing symobl record */
while (sym) {
if (strcmp(sym->symbol, symbol) == 0) {

View File

@ -448,9 +448,6 @@ 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;

View File

@ -318,15 +318,10 @@ 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 {

View File

@ -159,17 +159,6 @@ 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);
}

View File

@ -311,18 +311,14 @@ 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:

View File

@ -1,7 +1,6 @@
set (IWASM_COMPL_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${IWASM_COMPL_DIR})
enable_language(CXX)
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
file (GLOB_RECURSE source_all
@ -17,7 +16,7 @@ endif()
set (IWASM_COMPL_SOURCE ${source_all})
# Disable rtti to works with LLVM
# Disalbe rtti to works with LLVM
if (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")

View File

@ -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("Unsupported arith_op");
HANDLE_FAILURE("Unsupport arith_op");
break;
}

View File

@ -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 condition is met
* and then jumping to suitable label when the condtion 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 nothing if VOID
* @param r2 the label info when condition is unmet, do nonthing 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 overwriting edx when a.cdq() */
avoid overwritting 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 overwriting edx when unsigned extend
avoid overwritting 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 instruction */ \
again, 6 is the size of jmp instruciton */ \
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 containing the allocated code cacha info
* @param cc compiler context containting 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 replacement
* @param data_xchg the immediate data for exchange(conditionally replacment
* 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 replacement
* @param data_xchg the immediate data for exchange(conditionally replacment
* 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 argument registers */
/* Pop all integer arument 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 argument registers */
/* Pop all integer arument registers */
for (i = 0; i < MAX_REG_INTS; i++) {
a.pop(regs_i64[reg_idx_of_int_args[i]]);
}

View File

@ -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 comparison operation");
jit_set_last_error(cc, "unsupported comparation operation");
goto fail;
}

View File

@ -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, directly jump to
/* No need to create new basic block, direclty jump to
the existing basic block when no need to copy arities */
if (i == br_count) {
if (block_dst->label_type == LABEL_TYPE_LOOP) {

View File

@ -1,21 +1,14 @@
# 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_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)
endif ()
include_directories (${IWASM_FAST_JIT_DIR})
enable_language(CXX)
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
include(FetchContent)

View File

@ -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 doesn't have memory, reserve one mem_info space
/* If the module dosen'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 improperly */
may cause register spilling work inproperly */
if (!jit_emit_callnative(cc, os_time_thread_cputime_us, time_started, NULL,
0)) {
return NULL;

View File

@ -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
* registers. If this flag is set, the rest bits of the register
* regisers. 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 values of each kind. */
/* Constant vallues 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 comparison is about floating-point numbers or not
/* indicate if the last comparision 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 explicitly released.
* resources owned by the annotations must be explictely 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 existing
* non-zero, it is the result of the constant-folding or an exsiting
* 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.

View File

@ -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 constant register
* @return the spill slot encoded in a consant 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 allocate spill slot (due to OOM or frame size limit). */
/* Cannot allocte 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
* reload instruction will be inserted after the given instruction.
* reloade 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 reload instructions will be inserted
* yet. Necessary spill and reloade 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.
*

View File

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

View File

@ -46,7 +46,7 @@ extern "C" {
// Auxiliaries
// Machine types
#if defined(__STDC_VERSION__) && (__STDC_VERSION__) > 199901L
#if (__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");

View File

@ -23,8 +23,6 @@
#else
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
#endif
#elif defined(__GNUC__) || defined(__clang__)
#define WASM_RUNTIME_API_EXTERN __attribute__((visibility("default")))
#else
#define WASM_RUNTIME_API_EXTERN
#endif
@ -126,21 +124,6 @@ typedef WASMFunctionInstanceCommon *wasm_function_inst_t;
struct WASMMemoryInstance;
typedef struct WASMMemoryInstance *wasm_memory_inst_t;
typedef struct wasm_frame_t {
/* wasm_instance_t */
void *instance;
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;
@ -879,35 +862,6 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst,
WASM_RUNTIME_API_EXTERN void
wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env);
/**
* @brief Copy callstack frames.
*
* 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.
*
@ -1821,20 +1775,6 @@ 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
@ -2341,7 +2281,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 reuses part of the wasm
* @return return the allocated memory address, which re-uses 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.

View File

@ -1243,7 +1243,7 @@ wasm_value_type_size_internal(uint8 value_type, uint8 pointer_size)
return sizeof(int16);
#endif
else {
bh_assert(0 && "Unknown value type. It should be handled ahead.");
bh_assert(0);
}
#if WASM_ENABLE_GC == 0
(void)pointer_size;

View File

@ -1516,13 +1516,10 @@ 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() \
CHECK_INSTRUCTION_LIMIT(); \
FETCH_OPCODE_AND_DISPATCH()
#define HANDLE_OP_END() FETCH_OPCODE_AND_DISPATCH()
#endif
#else /* else of WASM_ENABLE_LABELS_AS_VALUES */
@ -1545,12 +1542,9 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
} \
os_mutex_unlock(&exec_env->wait_lock); \
} \
CHECK_INSTRUCTION_LIMIT(); \
continue;
#else
#define HANDLE_OP_END() \
CHECK_INSTRUCTION_LIMIT(); \
continue;
#define HANDLE_OP_END() continue
#endif
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
@ -1568,18 +1562,6 @@ 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,
@ -1623,14 +1605,6 @@ 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
@ -1960,7 +1934,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
UNWIND_CSP(relative_depth, LABEL_TYPE_FUNCTION);
/* push exception values for catch
* The values are copied to the CALLER FRAME
* (prev_frame->sp) same behavior ad WASM_OP_RETURN
* (prev_frame->sp) same behvior ad WASM_OP_RETURN
*/
if (cell_num_to_copy > 0) {
word_copy(prev_frame->sp,
@ -2675,7 +2649,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
read_leb_uint32(frame_ip, frame_ip_end, type_index);
func_obj = POP_REF();
if (!func_obj) {
wasm_set_exception(module, "null function reference");
wasm_set_exception(module, "null function object");
goto got_exception;
}
@ -2692,7 +2666,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
read_leb_uint32(frame_ip, frame_ip_end, type_index);
func_obj = POP_REF();
if (!func_obj) {
wasm_set_exception(module, "null function reference");
wasm_set_exception(module, "null function object");
goto got_exception;
}
@ -2839,8 +2813,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
struct_obj = POP_REF();
if (!struct_obj) {
wasm_set_exception(module,
"null structure reference");
wasm_set_exception(module, "null structure object");
goto got_exception;
}
@ -2896,8 +2869,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
struct_obj = POP_REF();
if (!struct_obj) {
wasm_set_exception(module,
"null structure reference");
wasm_set_exception(module, "null structure object");
goto got_exception;
}
@ -4989,7 +4961,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP_END();
}
/* numeric instructions of i32 */
/* numberic instructions of i32 */
HANDLE_OP(WASM_OP_I32_CLZ)
{
DEF_OP_BIT_COUNT(uint32, I32, clz32);
@ -5146,7 +5118,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP_END();
}
/* numeric instructions of i64 */
/* numberic instructions of i64 */
HANDLE_OP(WASM_OP_I64_CLZ)
{
DEF_OP_BIT_COUNT(uint64, I64, clz64);
@ -5303,7 +5275,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP_END();
}
/* numeric instructions of f32 */
/* numberic instructions of f32 */
HANDLE_OP(WASM_OP_F32_ABS)
{
DEF_OP_MATH(float32, F32, fabsf);
@ -5407,7 +5379,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP_END();
}
/* numeric instructions of f64 */
/* numberic instructions of f64 */
HANDLE_OP(WASM_OP_F64_ABS)
{
DEF_OP_MATH(float64, F64, fabs);
@ -5810,6 +5782,7 @@ 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();
@ -5822,17 +5795,24 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
/* skip dst memidx */
frame_ip += 1;
#endif
// TODO: apply memidx
#if WASM_ENABLE_THREAD_MGR != 0
linear_mem_size = get_linear_mem_size();
#endif
dlen = linear_mem_size - dst;
/* dst boundary check */
#ifndef OS_ENABLE_HW_BOUND_CHECK
CHECK_BULK_MEMORY_OVERFLOW(dst, len, mdst);
#if WASM_ENABLE_SHARED_HEAP != 0
if (app_addr_in_shared_heap((uint64)dst, len))
dlen = shared_heap_end_off - dst + 1;
#endif
#else /* else of OS_ENABLE_HW_BOUND_CHECK */
#if WASM_ENABLE_SHARED_HEAP != 0
if (app_addr_in_shared_heap((uint64)dst, len)) {
shared_heap_addr_app_to_native((uint64)dst, mdst);
dlen = shared_heap_end_off - dst + 1;
}
else
#endif
@ -5850,7 +5830,6 @@ 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
@ -5870,21 +5849,15 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
}
#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);
}
#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
break;
}
case WASM_OP_MEMORY_FILL:
@ -6705,7 +6678,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
tag++, t++) {
/* compare the module and the external index with the
* import tag data */
* imort tag data */
if ((cur_func->u.func_import->import_module
== tag->u.tag_import->import_module)
&& (ext_exception

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -48,9 +48,7 @@ is_table_64bit(WASMModule *module, uint32 table_idx)
return !!(module->import_tables[table_idx].u.table.table_type.flags
& TABLE64_FLAG);
else
return !!(module->tables[table_idx - module->import_table_count]
.table_type.flags
& TABLE64_FLAG);
return !!(module->tables[table_idx].table_type.flags & TABLE64_FLAG);
return false;
}
@ -208,14 +206,9 @@ memory_realloc(void *mem_old, uint32 size_old, uint32 size_new, char *error_buf,
{
uint8 *mem_new;
bh_assert(size_new > size_old);
if ((mem_new = wasm_runtime_realloc(mem_old, size_new))) {
memset(mem_new + size_old, 0, size_new - size_old);
return mem_new;
}
if ((mem_new = loader_malloc(size_new, error_buf, error_buf_size))) {
bh_memcpy_s(mem_new, size_new, mem_old, size_old);
memset(mem_new + size_old, 0, size_new - size_old);
wasm_runtime_free(mem_old);
}
return mem_new;
@ -665,7 +658,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, *p_org;
const uint8 *p = *p_buf, *p_end = buf_end;
uint32 declare_elem_type = 0, table_flag = 0, declare_init_size = 0,
declare_max_size = 0;
@ -678,12 +671,7 @@ 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;
@ -716,7 +704,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, *p_org;
const uint8 *p = *p_buf, *p_end = buf_end;
#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
@ -729,13 +717,7 @@ 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;
}
@ -826,8 +808,6 @@ 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);
@ -867,8 +847,6 @@ 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);
@ -1226,7 +1204,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
* we shall make a copy of code body [p_code, p_code + code_size]
* when we are worrying about inappropriate releasing behaviour.
* all code bodies are actually in a buffer which user allocates in
* their embedding environment and we don't have power over them.
* his embedding environment and we don't have power on them.
* it will be like:
* code_body_cp = malloc(code_size);
* memcpy(code_body_cp, p_code, code_size);
@ -2472,7 +2450,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 function instead of
/* Try to switch to call this llvm jit funtion instead of
fast jit function from fast jit jitted code */
jit_compiler_set_call_to_llvm_jit(
module,
@ -2493,7 +2471,6 @@ 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));
@ -2502,7 +2479,6 @@ orcjit_stop_compile_threads(WASMModule *module)
if (module->orcjit_threads[i])
os_thread_join(module->orcjit_threads[i], NULL);
}
#endif
}
static bool
@ -2590,7 +2566,7 @@ get_table_elem_type(const WASMModule *module, uint32 table_idx,
module->import_tables[table_idx].u.table.table_type.elem_type;
else
*p_elem_type =
module->tables[table_idx - module->import_table_count]
module->tables[module->import_table_count + table_idx]
.table_type.elem_type;
}
return true;
@ -2751,11 +2727,6 @@ load_from_sections(WASMModule *module, WASMSection *sections,
section = section->next;
}
#if WASM_ENABLE_BULK_MEMORY != 0
bh_assert(!has_datacount_section
|| module->data_seg_count == module->data_seg_count1);
#endif
module->aux_data_end_global_index = (uint32)-1;
module->aux_heap_base_global_index = (uint32)-1;
module->aux_stack_top_global_index = (uint32)-1;
@ -2765,12 +2736,6 @@ load_from_sections(WASMModule *module, WASMSection *sections,
for (i = 0; i < module->export_count; i++, export ++) {
if (export->kind == EXPORT_KIND_GLOBAL) {
if (!strcmp(export->name, "__heap_base")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __heap_base is imported "
"instead of being a local global");
continue;
}
global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
@ -2785,12 +2750,6 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
else if (!strcmp(export->name, "__data_end")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __data_end is imported "
"instead of being a local global");
continue;
}
global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
@ -2985,7 +2944,9 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
if (!module->possible_memory_grow) {
#if WASM_ENABLE_SHRUNK_MEMORY != 0
WASMMemoryImport *memory_import;
WASMMemory *memory;
if (aux_data_end_global && aux_heap_base_global
&& aux_stack_top_global) {
uint64 init_memory_size;
@ -2995,8 +2956,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
* valid range of uint32 */
if (shrunk_memory_size <= UINT32_MAX) {
if (module->import_memory_count) {
WASMMemoryImport *memory_import =
&module->import_memories[0].u.memory;
memory_import = &module->import_memories[0].u.memory;
init_memory_size =
(uint64)memory_import->mem_type.num_bytes_per_page
* memory_import->mem_type.init_page_count;
@ -3011,7 +2971,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
if (module->memory_count) {
WASMMemory *memory = &module->memories[0];
memory = &module->memories[0];
init_memory_size = (uint64)memory->num_bytes_per_page
* memory->init_page_count;
if (shrunk_memory_size <= init_memory_size) {
@ -3024,11 +2984,9 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
}
#endif /* WASM_ENABLE_SHRUNK_MEMORY != 0 */
if (module->import_memory_count) {
WASMMemoryImport *memory_import =
&module->import_memories[0].u.memory;
memory_import = &module->import_memories[0].u.memory;
if (memory_import->mem_type.init_page_count < DEFAULT_MAX_PAGES) {
memory_import->mem_type.num_bytes_per_page *=
memory_import->mem_type.init_page_count;
@ -3042,7 +3000,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
if (module->memory_count) {
WASMMemory *memory = &module->memories[0];
memory = &module->memories[0];
if (memory->init_page_count < DEFAULT_MAX_PAGES) {
memory->num_bytes_per_page *= memory->init_page_count;
if (memory->init_page_count > 0)
@ -3139,18 +3097,6 @@ 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;
}
@ -4086,16 +4032,11 @@ typedef struct WASMLoaderContext {
/* preserved local offset */
int16 preserved_local_offset;
/* const buffer for i64 and f64 consts, note that the raw bytes
* of i64 and f64 are the same, so we read an i64 value from an
* f64 const with its raw bytes, something like `*(int64 *)&f64 */
int64 *i64_consts;
uint32 i64_const_max_num;
uint32 i64_const_num;
/* const buffer for i32 and f32 consts */
int32 *i32_consts;
uint32 i32_const_max_num;
uint32 i32_const_num;
/* const buffer */
uint8 *const_buf;
uint16 num_const;
uint16 const_cell_num;
uint32 const_buf_size;
/* processed code */
uint8 *p_code_compiled;
@ -4108,6 +4049,12 @@ typedef struct WASMLoaderContext {
#endif
} WASMLoaderContext;
typedef struct Const {
WASMValue value;
uint16 slot_index;
uint8 value_type;
} Const;
#define CHECK_CSP_PUSH() \
do { \
if (ctx->frame_csp >= ctx->frame_csp_boundary) { \
@ -4262,10 +4209,8 @@ wasm_loader_ctx_destroy(WASMLoaderContext *ctx)
#if WASM_ENABLE_FAST_INTERP != 0
if (ctx->frame_offset_bottom)
wasm_runtime_free(ctx->frame_offset_bottom);
if (ctx->i64_consts)
wasm_runtime_free(ctx->i64_consts);
if (ctx->i32_consts)
wasm_runtime_free(ctx->i32_consts);
if (ctx->const_buf)
wasm_runtime_free(ctx->const_buf);
#endif
wasm_runtime_free(ctx);
}
@ -4299,15 +4244,10 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size)
goto fail;
loader_ctx->frame_offset_boundary = loader_ctx->frame_offset_bottom + 32;
loader_ctx->i64_const_max_num = 8;
if (!(loader_ctx->i64_consts =
loader_malloc(sizeof(int64) * loader_ctx->i64_const_max_num,
error_buf, error_buf_size)))
goto fail;
loader_ctx->i32_const_max_num = 8;
if (!(loader_ctx->i32_consts =
loader_malloc(sizeof(int32) * loader_ctx->i32_const_max_num,
error_buf, error_buf_size)))
loader_ctx->num_const = 0;
loader_ctx->const_buf_size = sizeof(Const) * 8;
if (!(loader_ctx->const_buf = loader_malloc(loader_ctx->const_buf_size,
error_buf, error_buf_size)))
goto fail;
if (func->param_cell_num >= (int32)INT16_MAX - func->local_cell_num) {
@ -4792,11 +4732,6 @@ 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);
@ -5135,116 +5070,107 @@ wasm_loader_push_pop_frame_ref_offset(WASMLoaderContext *ctx, uint8 pop_cnt,
return true;
}
static int
cmp_i64_const(const void *p_i64_const1, const void *p_i64_const2)
{
int64 i64_const1 = *(int64 *)p_i64_const1;
int64 i64_const2 = *(int64 *)p_i64_const2;
return (i64_const1 < i64_const2) ? -1 : (i64_const1 > i64_const2) ? 1 : 0;
}
static int
cmp_i32_const(const void *p_i32_const1, const void *p_i32_const2)
{
int32 i32_const1 = *(int32 *)p_i32_const1;
int32 i32_const2 = *(int32 *)p_i32_const2;
return (i32_const1 < i32_const2) ? -1 : (i32_const1 > i32_const2) ? 1 : 0;
}
static bool
wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value,
int16 *offset, char *error_buf,
uint32 error_buf_size)
{
if (!ctx->p_code_compiled) {
/* Treat i64 and f64 as the same by reading i64 value from
the raw bytes */
if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) {
/* No slot left, emit const instead */
if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 2) {
*offset = 0;
return true;
}
int8 bytes_to_increase;
int16 operand_offset = 0;
Const *c;
/* Traverse the list if the const num is small */
if (ctx->i64_const_num < 10) {
for (uint32 i = 0; i < ctx->i64_const_num; i++) {
if (ctx->i64_consts[i] == *(int64 *)value) {
*offset = -1;
return true;
}
}
}
/* Search existing constant */
for (c = (Const *)ctx->const_buf;
(uint8 *)c < ctx->const_buf + ctx->num_const * sizeof(Const); c++) {
if ((type == c->value_type)
&& ((type == VALUE_TYPE_I64 && *(int64 *)value == c->value.i64)
|| (type == VALUE_TYPE_I32 && *(int32 *)value == c->value.i32)
#if WASM_ENABLE_REF_TYPES != 0
|| (type == VALUE_TYPE_FUNCREF
&& *(int32 *)value == c->value.i32)
|| (type == VALUE_TYPE_EXTERNREF
&& *(int32 *)value == c->value.i32)
#endif
|| (type == VALUE_TYPE_F64
&& (0 == memcmp(value, &(c->value.f64), sizeof(float64))))
|| (type == VALUE_TYPE_F32
&& (0
== memcmp(value, &(c->value.f32), sizeof(float32)))))) {
operand_offset = c->slot_index;
break;
}
if (c->value_type == VALUE_TYPE_I64 || c->value_type == VALUE_TYPE_F64)
operand_offset += 2;
else
operand_offset += 1;
}
if (ctx->i64_const_num >= ctx->i64_const_max_num) {
MEM_REALLOC(ctx->i64_consts,
sizeof(int64) * ctx->i64_const_max_num,
sizeof(int64) * (ctx->i64_const_max_num * 2));
ctx->i64_const_max_num *= 2;
}
ctx->i64_consts[ctx->i64_const_num++] = *(int64 *)value;
if ((uint8 *)c == ctx->const_buf + ctx->num_const * sizeof(Const)) {
/* New constant, append to the const buffer */
if ((type == VALUE_TYPE_F64) || (type == VALUE_TYPE_I64)) {
bytes_to_increase = 2;
}
else {
/* Treat i32 and f32 as the same by reading i32 value from
the raw bytes */
bh_assert(type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32);
/* No slot left, emit const instead */
if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 1) {
*offset = 0;
return true;
}
/* Traverse the list if the const num is small */
if (ctx->i32_const_num < 10) {
for (uint32 i = 0; i < ctx->i32_const_num; i++) {
if (ctx->i32_consts[i] == *(int32 *)value) {
*offset = -1;
return true;
}
}
}
if (ctx->i32_const_num >= ctx->i32_const_max_num) {
MEM_REALLOC(ctx->i32_consts,
sizeof(int32) * ctx->i32_const_max_num,
sizeof(int32) * (ctx->i32_const_max_num * 2));
ctx->i32_const_max_num *= 2;
}
ctx->i32_consts[ctx->i32_const_num++] = *(int32 *)value;
bytes_to_increase = 1;
}
*offset = -1;
return true;
}
else {
if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) {
int64 key = *(int64 *)value, *i64_const;
i64_const = bsearch(&key, ctx->i64_consts, ctx->i64_const_num,
sizeof(int64), cmp_i64_const);
if (!i64_const) { /* not found, emit const instead */
*offset = 0;
return true;
}
*offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num)
+ (uint32)(i64_const - ctx->i64_consts) * 2;
}
else {
int32 key = *(int32 *)value, *i32_const;
i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num,
sizeof(int32), cmp_i32_const);
if (!i32_const) { /* not found, emit const instead */
*offset = 0;
return true;
}
*offset = -(uint32)(ctx->i32_const_num)
+ (uint32)(i32_const - ctx->i32_consts);
}
return true;
/* The max cell num of const buffer is 32768 since the valid index range
* is -32768 ~ -1. Return an invalid index 0 to indicate the buffer is
* full */
if (ctx->const_cell_num > INT16_MAX - bytes_to_increase + 1) {
*offset = 0;
return true;
}
if ((uint8 *)c == ctx->const_buf + ctx->const_buf_size) {
MEM_REALLOC(ctx->const_buf, ctx->const_buf_size,
ctx->const_buf_size + 4 * sizeof(Const));
ctx->const_buf_size += 4 * sizeof(Const);
c = (Const *)(ctx->const_buf + ctx->num_const * sizeof(Const));
}
c->value_type = type;
switch (type) {
case VALUE_TYPE_F64:
bh_memcpy_s(&(c->value.f64), sizeof(WASMValue), value,
sizeof(float64));
ctx->const_cell_num += 2;
/* The const buf will be reversed, we use the second cell */
/* of the i64/f64 const so the finnal offset is corrent */
operand_offset++;
break;
case VALUE_TYPE_I64:
c->value.i64 = *(int64 *)value;
ctx->const_cell_num += 2;
operand_offset++;
break;
case VALUE_TYPE_F32:
bh_memcpy_s(&(c->value.f32), sizeof(WASMValue), value,
sizeof(float32));
ctx->const_cell_num++;
break;
case VALUE_TYPE_I32:
c->value.i32 = *(int32 *)value;
ctx->const_cell_num++;
break;
#if WASM_ENABLE_REF_TYPES != 0
case VALUE_TYPE_EXTERNREF:
case VALUE_TYPE_FUNCREF:
c->value.i32 = *(int32 *)value;
ctx->const_cell_num++;
break;
#endif
default:
break;
}
c->slot_index = operand_offset;
ctx->num_const++;
LOG_OP("#### new const [%d]: %ld\n", ctx->num_const,
(int64)c->value.i64);
}
/* use negetive index for const */
operand_offset = -(operand_offset + 1);
*offset = operand_offset;
return true;
fail:
return false;
}
@ -6107,86 +6033,6 @@ fail:
} \
} while (0)
#if WASM_ENABLE_FAST_INTERP == 0
#define pb_read_leb_uint32 read_leb_uint32
#define pb_read_leb_int32 read_leb_int32
#define pb_read_leb_int64 read_leb_int64
#define pb_read_leb_memarg read_leb_memarg
#define pb_read_leb_mem_offset read_leb_mem_offset
#define pb_read_leb_memidx read_leb_memidx
#else
/* Read leb without malformed format check */
static uint64
read_leb_quick(uint8 **p_buf, uint32 maxbits, bool sign)
{
uint8 *buf = *p_buf;
uint64 result = 0, byte = 0;
uint32 shift = 0;
do {
byte = *buf++;
result |= ((byte & 0x7f) << shift);
shift += 7;
} while (byte & 0x80);
if (sign && (shift < maxbits) && (byte & 0x40)) {
/* Sign extend */
result |= (~((uint64)0)) << shift;
}
*p_buf = buf;
return result;
}
#define pb_read_leb_uint32(p, p_end, res) \
do { \
if (!loader_ctx->p_code_compiled) \
/* Enable format check in the first scan */ \
read_leb_uint32(p, p_end, res); \
else \
/* Disable format check in the second scan */ \
res = (uint32)read_leb_quick(&p, 32, false); \
} while (0)
#define pb_read_leb_int32(p, p_end, res) \
do { \
if (!loader_ctx->p_code_compiled) \
/* Enable format check in the first scan */ \
read_leb_int32(p, p_end, res); \
else \
/* Disable format check in the second scan */ \
res = (int32)read_leb_quick(&p, 32, true); \
} while (0)
#define pb_read_leb_int64(p, p_end, res) \
do { \
if (!loader_ctx->p_code_compiled) \
/* Enable format check in the first scan */ \
read_leb_int64(p, p_end, res); \
else \
/* Disable format check in the second scan */ \
res = (int64)read_leb_quick(&p, 64, true); \
} while (0)
#if WASM_ENABLE_MULTI_MEMORY != 0
#define pb_read_leb_memarg read_leb_memarg
#else
#define pb_read_leb_memarg pb_read_leb_uint32
#endif
#if WASM_ENABLE_MEMORY64 != 0
#define pb_read_leb_mem_offset read_leb_mem_offset
#else
#define pb_read_leb_mem_offset pb_read_leb_uint32
#endif
#define pb_read_leb_memidx pb_read_leb_uint32
#endif /* end of WASM_ENABLE_FAST_INTERP != 0 */
static bool
wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
uint32 cur_func_idx, char *error_buf,
@ -6210,9 +6056,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
uint32 segment_index;
#endif
#if WASM_ENABLE_FAST_INTERP != 0
uint8 *func_const_end, *func_const = NULL;
int16 operand_offset = 0;
uint8 last_op = 0;
bool disable_emit, preserve_local = false, if_condition_available = true;
;
float32 f32_const;
float64 f64_const;
@ -6263,68 +6111,6 @@ re_scan:
p = func->code;
func->code_compiled = loader_ctx->p_code_compiled;
func->code_compiled_size = loader_ctx->code_compiled_size;
if (loader_ctx->i64_const_num > 0) {
int64 *i64_consts_old = loader_ctx->i64_consts;
/* Sort the i64 consts */
qsort(i64_consts_old, loader_ctx->i64_const_num, sizeof(int64),
cmp_i64_const);
/* Remove the duplicated i64 consts */
uint32 k = 1;
for (i = 1; i < loader_ctx->i64_const_num; i++) {
if (i64_consts_old[i] != i64_consts_old[i - 1]) {
i64_consts_old[k++] = i64_consts_old[i];
}
}
if (k < loader_ctx->i64_const_num) {
int64 *i64_consts_new;
/* Try to reallocate memory with a smaller size */
if ((i64_consts_new =
wasm_runtime_malloc((uint32)sizeof(int64) * k))) {
bh_memcpy_s(i64_consts_new, (uint32)sizeof(int64) * k,
i64_consts_old, (uint32)sizeof(int64) * k);
/* Free the old memory */
wasm_runtime_free(i64_consts_old);
loader_ctx->i64_consts = i64_consts_new;
loader_ctx->i64_const_max_num = k;
}
loader_ctx->i64_const_num = k;
}
}
if (loader_ctx->i32_const_num > 0) {
int32 *i32_consts_old = loader_ctx->i32_consts;
/* Sort the i32 consts */
qsort(i32_consts_old, loader_ctx->i32_const_num, sizeof(int32),
cmp_i32_const);
/* Remove the duplicated i32 consts */
uint32 k = 1;
for (i = 1; i < loader_ctx->i32_const_num; i++) {
if (i32_consts_old[i] != i32_consts_old[i - 1]) {
i32_consts_old[k++] = i32_consts_old[i];
}
}
if (k < loader_ctx->i32_const_num) {
int32 *i32_consts_new;
/* Try to reallocate memory with a smaller size */
if ((i32_consts_new =
wasm_runtime_malloc((uint32)sizeof(int32) * k))) {
bh_memcpy_s(i32_consts_new, (uint32)sizeof(int32) * k,
i32_consts_old, (uint32)sizeof(int32) * k);
/* Free the old memory */
wasm_runtime_free(i32_consts_old);
loader_ctx->i32_consts = i32_consts_new;
loader_ctx->i32_const_max_num = k;
}
loader_ctx->i32_const_num = k;
}
}
}
#endif
@ -6394,7 +6180,7 @@ re_scan:
int32 type_index;
/* Resolve the leb128 encoded type index as block type */
p--;
pb_read_leb_int32(p, p_end, type_index);
read_leb_int32(p, p_end, type_index);
bh_assert((uint32)type_index < module->type_count);
block_type.is_value_type = false;
block_type.u.type = module->types[type_index];
@ -6707,7 +6493,7 @@ re_scan:
uint32 j;
#endif
pb_read_leb_uint32(p, p_end, count);
read_leb_uint32(p, p_end, count);
#if WASM_ENABLE_FAST_INTERP != 0
emit_uint32(loader_ctx, count);
#endif
@ -6716,7 +6502,7 @@ re_scan:
/* Get each depth and check it */
p_org = p;
for (i = 0; i <= count; i++) {
pb_read_leb_uint32(p, p_end, depth);
read_leb_uint32(p, p_end, depth);
bh_assert(loader_ctx->csp_num > 0);
bh_assert(loader_ctx->csp_num - 1 >= depth);
(void)depth;
@ -6814,7 +6600,7 @@ re_scan:
uint32 func_idx;
int32 idx;
pb_read_leb_uint32(p, p_end, func_idx);
read_leb_uint32(p, p_end, func_idx);
#if WASM_ENABLE_FAST_INTERP != 0
/* we need to emit func_idx before arguments */
emit_uint32(loader_ctx, func_idx);
@ -6887,10 +6673,10 @@ re_scan:
bh_assert(module->import_table_count + module->table_count > 0);
pb_read_leb_uint32(p, p_end, type_idx);
read_leb_uint32(p, p_end, type_idx);
#if WASM_ENABLE_REF_TYPES != 0
pb_read_leb_uint32(p, p_end, table_idx);
read_leb_uint32(p, p_end, table_idx);
#else
CHECK_BUF(p, p_end, 1);
table_idx = read_uint8(p);
@ -6900,15 +6686,6 @@ re_scan:
goto fail;
}
bh_assert(
(table_idx < module->import_table_count
? module->import_tables[table_idx]
.u.table.table_type.elem_type
: module
->tables[table_idx - module->import_table_count]
.table_type.elem_type)
== VALUE_TYPE_FUNCREF);
#if WASM_ENABLE_FAST_INTERP != 0
/* we need to emit before arguments */
emit_uint32(loader_ctx, type_idx);
@ -7130,7 +6907,7 @@ re_scan:
uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled;
#endif
pb_read_leb_uint32(p, p_end, vec_len);
read_leb_uint32(p, p_end, vec_len);
if (vec_len != 1) {
/* typed select must have exactly one result */
set_error_buf(error_buf, error_buf_size,
@ -7205,7 +6982,7 @@ re_scan:
uint8 decl_ref_type;
uint32 table_idx;
pb_read_leb_uint32(p, p_end, table_idx);
read_leb_uint32(p, p_end, table_idx);
if (!get_table_elem_type(module, table_idx, &decl_ref_type,
error_buf, error_buf_size))
goto fail;
@ -7299,7 +7076,7 @@ re_scan:
case WASM_OP_REF_FUNC:
{
uint32 func_idx = 0;
pb_read_leb_uint32(p, p_end, func_idx);
read_leb_uint32(p, p_end, func_idx);
if (!check_function_index(module, func_idx, error_buf,
error_buf_size)) {
@ -7516,7 +7293,7 @@ re_scan:
case WASM_OP_GET_GLOBAL:
{
p_org = p - 1;
pb_read_leb_uint32(p, p_end, global_idx);
read_leb_uint32(p, p_end, global_idx);
bh_assert(global_idx < global_count);
global_type = global_idx < module->import_global_count
@ -7550,7 +7327,7 @@ re_scan:
bool is_mutable = false;
p_org = p - 1;
pb_read_leb_uint32(p, p_end, global_idx);
read_leb_uint32(p, p_end, global_idx);
bh_assert(global_idx < global_count);
is_mutable = global_idx < module->import_global_count
@ -7647,8 +7424,8 @@ re_scan:
}
#endif
CHECK_MEMORY();
pb_read_leb_memarg(p, p_end, align); /* align */
pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */
read_leb_memarg(p, p_end, align); /* align */
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
#if WASM_ENABLE_FAST_INTERP != 0
emit_uint32(loader_ctx, mem_offset);
#endif
@ -7709,7 +7486,7 @@ re_scan:
case WASM_OP_MEMORY_SIZE:
CHECK_MEMORY();
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
PUSH_PAGE_COUNT();
@ -7721,7 +7498,7 @@ re_scan:
case WASM_OP_MEMORY_GROW:
CHECK_MEMORY();
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
POP_AND_PUSH(mem_offset_type, mem_offset_type);
@ -7736,7 +7513,7 @@ re_scan:
break;
case WASM_OP_I32_CONST:
pb_read_leb_int32(p, p_end, i32_const);
read_leb_int32(p, p_end, i32_const);
#if WASM_ENABLE_FAST_INTERP != 0
skip_label();
disable_emit = true;
@ -7754,7 +7531,7 @@ re_scan:
break;
case WASM_OP_I64_CONST:
pb_read_leb_int64(p, p_end, i64_const);
read_leb_int64(p, p_end, i64_const);
#if WASM_ENABLE_FAST_INTERP != 0
skip_label();
disable_emit = true;
@ -8036,7 +7813,7 @@ re_scan:
{
uint32 opcode1;
pb_read_leb_uint32(p, p_end, opcode1);
read_leb_uint32(p, p_end, opcode1);
#if WASM_ENABLE_FAST_INTERP != 0
emit_byte(loader_ctx, ((uint8)opcode1));
#endif
@ -8061,11 +7838,11 @@ re_scan:
case WASM_OP_MEMORY_INIT:
{
CHECK_MEMORY();
pb_read_leb_uint32(p, p_end, segment_index);
read_leb_uint32(p, p_end, segment_index);
#if WASM_ENABLE_FAST_INTERP != 0
emit_uint32(loader_ctx, segment_index);
#endif
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
bh_assert(segment_index < module->data_seg_count);
@ -8081,7 +7858,7 @@ re_scan:
}
case WASM_OP_DATA_DROP:
{
pb_read_leb_uint32(p, p_end, segment_index);
read_leb_uint32(p, p_end, segment_index);
#if WASM_ENABLE_FAST_INTERP != 0
emit_uint32(loader_ctx, segment_index);
#endif
@ -8097,9 +7874,9 @@ re_scan:
CHECK_MEMORY();
CHECK_BUF(p, p_end, sizeof(int16));
/* check both src and dst memory index */
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
POP_MEM_OFFSET();
@ -8113,7 +7890,7 @@ re_scan:
case WASM_OP_MEMORY_FILL:
{
CHECK_MEMORY();
pb_read_leb_memidx(p, p_end, memidx);
read_leb_memidx(p, p_end, memidx);
check_memidx(module, memidx);
POP_MEM_OFFSET();
@ -8131,8 +7908,8 @@ re_scan:
uint8 seg_ref_type, tbl_ref_type;
uint32 table_seg_idx, table_idx;
pb_read_leb_uint32(p, p_end, table_seg_idx);
pb_read_leb_uint32(p, p_end, table_idx);
read_leb_uint32(p, p_end, table_seg_idx);
read_leb_uint32(p, p_end, table_idx);
if (!get_table_elem_type(module, table_idx,
&tbl_ref_type, error_buf,
@ -8167,7 +7944,7 @@ re_scan:
case WASM_OP_ELEM_DROP:
{
uint32 table_seg_idx;
pb_read_leb_uint32(p, p_end, table_seg_idx);
read_leb_uint32(p, p_end, table_seg_idx);
if (!get_table_seg_elem_type(module, table_seg_idx,
NULL, error_buf,
error_buf_size))
@ -8183,13 +7960,13 @@ re_scan:
uint32 src_tbl_idx, dst_tbl_idx, src_tbl_idx_type,
dst_tbl_idx_type, min_tbl_idx_type;
pb_read_leb_uint32(p, p_end, src_tbl_idx);
read_leb_uint32(p, p_end, src_tbl_idx);
if (!get_table_elem_type(module, src_tbl_idx,
&src_ref_type, error_buf,
error_buf_size))
goto fail;
pb_read_leb_uint32(p, p_end, dst_tbl_idx);
read_leb_uint32(p, p_end, dst_tbl_idx);
if (!get_table_elem_type(module, dst_tbl_idx,
&dst_ref_type, error_buf,
error_buf_size))
@ -8236,7 +8013,7 @@ re_scan:
{
uint32 table_idx;
pb_read_leb_uint32(p, p_end, table_idx);
read_leb_uint32(p, p_end, table_idx);
/* TODO: shall we create a new function to check
table idx instead of using below function? */
if (!get_table_elem_type(module, table_idx, NULL,
@ -8261,7 +8038,7 @@ re_scan:
uint8 decl_ref_type;
uint32 table_idx;
pb_read_leb_uint32(p, p_end, table_idx);
read_leb_uint32(p, p_end, table_idx);
if (!get_table_elem_type(module, table_idx,
&decl_ref_type, error_buf,
error_buf_size))
@ -8313,15 +8090,15 @@ re_scan:
{
uint32 opcode1;
pb_read_leb_uint32(p, p_end, opcode1);
read_leb_uint32(p, p_end, opcode1);
#if WASM_ENABLE_FAST_INTERP != 0
emit_byte(loader_ctx, opcode1);
#endif
if (opcode1 != WASM_OP_ATOMIC_FENCE) {
CHECK_MEMORY();
pb_read_leb_uint32(p, p_end, align); /* align */
pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */
read_leb_uint32(p, p_end, align); /* align */
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
#if WASM_ENABLE_FAST_INTERP != 0
emit_uint32(loader_ctx, mem_offset);
#endif
@ -8471,25 +8248,29 @@ re_scan:
if (loader_ctx->p_code_compiled == NULL)
goto re_scan;
func->const_cell_num =
loader_ctx->i64_const_num * 2 + loader_ctx->i32_const_num;
func->const_cell_num = loader_ctx->const_cell_num;
if (func->const_cell_num > 0) {
if (!(func->consts =
loader_malloc((uint64)sizeof(uint32) * func->const_cell_num,
error_buf, error_buf_size)))
int32 j;
if (!(func->consts = func_const = loader_malloc(
func->const_cell_num * 4, error_buf, error_buf_size)))
goto fail;
if (loader_ctx->i64_const_num > 0) {
bh_memcpy_s(func->consts,
(uint32)sizeof(int64) * loader_ctx->i64_const_num,
loader_ctx->i64_consts,
(uint32)sizeof(int64) * loader_ctx->i64_const_num);
}
if (loader_ctx->i32_const_num > 0) {
bh_memcpy_s(func->consts
+ sizeof(int64) * loader_ctx->i64_const_num,
(uint32)sizeof(int32) * loader_ctx->i32_const_num,
loader_ctx->i32_consts,
(uint32)sizeof(int32) * loader_ctx->i32_const_num);
func_const_end = func->consts + func->const_cell_num * 4;
/* reverse the const buf */
for (j = loader_ctx->num_const - 1; j >= 0; j--) {
Const *c = (Const *)(loader_ctx->const_buf + j * sizeof(Const));
if (c->value_type == VALUE_TYPE_F64
|| c->value_type == VALUE_TYPE_I64) {
bh_memcpy_s(func_const, (uint32)(func_const_end - func_const),
&(c->value.f64), (uint32)sizeof(int64));
func_const += sizeof(int64);
}
else {
bh_memcpy_s(func_const, (uint32)(func_const_end - func_const),
&(c->value.f32), (uint32)sizeof(int32));
func_const += sizeof(int32);
}
}
}

View File

@ -278,16 +278,6 @@ 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,
@ -789,27 +779,16 @@ typedef enum WASMAtomicEXTOpcode {
#else
#define DEF_DEBUG_BREAK_HANDLE()
#endif
#define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode)
#if WASM_ENABLE_SIMDE != 0
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SIMD != 0
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \
SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX),
#else
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
#endif
#if WASM_ENABLE_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.
*/
@ -1041,7 +1020,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_EXT_V128_HANDLE() \
DEF_DEBUG_BREAK_HANDLE() \
};
#ifdef __cplusplus

View File

@ -3523,6 +3523,13 @@ 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");
@ -3541,13 +3548,6 @@ 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,55 +4195,6 @@ 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)
@ -4709,7 +4660,7 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
if (!(func_obj = wasm_create_func_obj(module_inst,
init_values[i].u.ref_index,
true, NULL, 0))) {
wasm_set_exception(module_inst, "null function reference");
wasm_set_exception(module_inst, "null function object");
return;
}
table_elems[i] = func_obj;

View File

@ -730,14 +730,6 @@ 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);

View File

@ -58,7 +58,7 @@ static WASMDebugEngine *g_debug_engine;
static uint32 current_instance_id = 1;
static uint32
allocate_instance_id(void)
allocate_instance_id()
{
uint32 id;
@ -302,7 +302,7 @@ wasm_debug_control_thread_destroy(WASMDebugInstance *debug_instance)
}
static WASMDebugEngine *
wasm_debug_engine_create(void)
wasm_debug_engine_create()
{
WASMDebugEngine *engine;
@ -326,7 +326,7 @@ wasm_debug_engine_create(void)
}
void
wasm_debug_engine_destroy(void)
wasm_debug_engine_destroy()
{
if (g_debug_engine) {
wasm_debug_handler_deinit();
@ -743,7 +743,7 @@ wasm_debug_instance_get_obj_mem(WASMDebugInstance *instance, uint64 offset,
module_inst = (WASMModuleInstance *)exec_env->module_inst;
if (offset + *size > module_inst->module->load_size) {
LOG_VERBOSE("wasm_debug_instance_get_data_mem size overflow!\n");
LOG_VERBOSE("wasm_debug_instance_get_data_mem size over flow!\n");
*size = module_inst->module->load_size >= offset
? module_inst->module->load_size - offset
: 0;
@ -797,7 +797,7 @@ wasm_debug_instance_get_linear_mem(WASMDebugInstance *instance, uint64 offset,
num_bytes_per_page = memory->num_bytes_per_page;
linear_mem_size = num_bytes_per_page * memory->cur_page_count;
if (offset + *size > linear_mem_size) {
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n");
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n");
*size = linear_mem_size >= offset ? linear_mem_size - offset : 0;
}
bh_memcpy_s(buf, (uint32)*size, memory->memory_data + offset,
@ -830,7 +830,7 @@ wasm_debug_instance_set_linear_mem(WASMDebugInstance *instance, uint64 offset,
num_bytes_per_page = memory->num_bytes_per_page;
linear_mem_size = num_bytes_per_page * memory->cur_page_count;
if (offset + *size > linear_mem_size) {
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n");
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n");
*size = linear_mem_size >= offset ? linear_mem_size - offset : 0;
}
bh_memcpy_s(memory->memory_data + offset, (uint32)*size, buf,

View File

@ -133,7 +133,7 @@ bool
wasm_debug_engine_init(char *ip_addr, int32 process_port);
void
wasm_debug_engine_destroy(void);
wasm_debug_engine_destroy();
WASMExecEnv *
wasm_debug_instance_get_current_env(WASMDebugInstance *instance);

Some files were not shown because too many files have changed in this diff Show More