Implement Exception Handling for classic interpreter (#3096)

This PR adds the initial support for WASM exception handling:
* Inside the classic interpreter only:
  * Initial handling of Tags
  * Initial handling of Exceptions based on W3C Exception Proposal
  * Import and Export of Exceptions and Tags
* Add `cmake -DWAMR_BUILD_EXCE_HANDLING=1/0` option to enable/disable
  the feature, and by default it is disabled
* Update the wamr-test-suites scripts to test the feature
* Additional CI/CD changes to validate the exception spec proposal cases

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1884
587513f3c6
8bebfe9ad7
59bccdfed8

Signed-off-by: Ricardo Aguilar <ricardoaguilar@siemens.com>
Co-authored-by: Chris Woods <chris.woods@siemens.com>
Co-authored-by: Rene Ermler <rene.ermler@siemens.com>
Co-authored-by: Trenner Thomas <trenner.thomas@siemens.com>
This commit is contained in:
Wenyong Huang
2024-01-31 08:27:17 +08:00
committed by GitHub
parent 7e65f9a244
commit af318bac81
16 changed files with 1620 additions and 39 deletions

View File

@ -24,6 +24,7 @@ function help()
echo "-S enable SIMD feature"
echo "-G enable GC feature"
echo "-X enable XIP feature"
echo "-e enable exception handling"
echo "-x test SGX"
echo "-w enable WASI threads"
echo "-b use the wabt binary release package instead of compiling from the source code"
@ -50,6 +51,7 @@ COLLECT_CODE_COVERAGE=0
ENABLE_SIMD=0
ENABLE_GC=0
ENABLE_XIP=0
ENABLE_EH=0
ENABLE_DEBUG_VERSION=0
ENABLE_GC_HEAP_VERIFY=0
#unit test case arrary
@ -70,7 +72,7 @@ WASI_TESTSUITE_COMMIT="ee807fc551978490bf1c277059aabfa1e589a6c2"
TARGET_LIST=("AARCH64" "AARCH64_VFP" "ARMV7" "ARMV7_VFP" "THUMBV7" "THUMBV7_VFP" \
"RISCV32" "RISCV32_ILP32F" "RISCV32_ILP32D" "RISCV64" "RISCV64_LP64F" "RISCV64_LP64D")
while getopts ":s:cabgvt:m:MCpSXxwPGQF:j:T:" opt
while getopts ":s:cabgvt:m:MCpSXexwPGQF:j:T:" opt
do
OPT_PARSED="TRUE"
case $opt in
@ -145,6 +147,10 @@ do
echo "enable XIP feature"
ENABLE_XIP=1
;;
e)
echo "enable exception handling feature"
ENABLE_EH=1
;;
x)
echo "test SGX"
SGX_OPT="--sgx"
@ -425,6 +431,26 @@ function spec_test()
git apply ../../spec-test-script/thread_proposal_fix_atomic_case.patch
fi
if [ ${ENABLE_EH} == 1 ]; then
echo "checkout exception-handling test cases"
popd
if [ ! -d "exception-handling" ];then
echo "exception-handling not exist, clone it from github"
git clone -b master --single-branch https://github.com/WebAssembly/exception-handling
fi
pushd exception-handling
# restore and clean everything
git reset --hard 51c721661b671bb7dc4b3a3acb9e079b49778d36
if [[ ${ENABLE_MULTI_MODULE} == 0 ]]; then
git apply ../../spec-test-script/exception_handling.patch
fi
popd
echo $(pwd)
fi
# update GC cases
if [[ ${ENABLE_GC} == 1 ]]; then
echo "checkout spec for GC proposal"
@ -463,6 +489,10 @@ function spec_test()
fi
fi
if [[ 1 == ${ENABLE_EH} ]]; then
ARGS_FOR_SPEC_TEST+="-e "
fi
# sgx only enable in interp mode and aot mode
if [[ ${SGX_OPT} == "--sgx" ]];then
if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' || $1 == 'fast-jit' ]]; then
@ -827,6 +857,10 @@ function trigger()
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=1"
fi
if [[ ${ENABLE_EH} == 1 ]]; then
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_EXCE_HANDLING=1"
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_TAIL_CALL=1"
fi
echo "SANITIZER IS" $WAMR_BUILD_SANITIZER
if [[ "$WAMR_BUILD_SANITIZER" == "ubsan" ]]; then