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

@ -47,6 +47,7 @@ IWASM_CMD = get_iwasm_cmd(PLATFORM_NAME)
IWASM_SGX_CMD = "../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm"
IWASM_QEMU_CMD = "iwasm"
SPEC_TEST_DIR = "spec/test/core"
EXCE_HANDLING_DIR = "exception-handling/test/core"
WAST2WASM_CMD = exe_file_path("./wabt/out/gcc/Release/wat2wasm")
SPEC_INTERPRETER_CMD = "spec/interpreter/wasm"
WAMRC_CMD = "../../../wamr-compiler/build/wamrc"
@ -78,8 +79,10 @@ def ignore_the_case(
simd_flag=False,
gc_flag=False,
xip_flag=False,
eh_flag=False,
qemu_flag=False,
):
if case_name in ["comments", "inline-module", "names"]:
return True
@ -126,7 +129,7 @@ def ignore_the_case(
return False
def preflight_check(aot_flag):
def preflight_check(aot_flag, eh_flag):
if not pathlib.Path(SPEC_TEST_DIR).resolve().exists():
print(f"Can not find {SPEC_TEST_DIR}")
return False
@ -139,6 +142,10 @@ def preflight_check(aot_flag):
print(f"Can not find {WAMRC_CMD}")
return False
if eh_flag and not pathlib.Path(EXCE_HANDLING_DIR).resolve().exists():
print(f"Can not find {EXCE_HANDLING_DIR}")
return False
return True
@ -151,6 +158,7 @@ def test_case(
multi_thread_flag=False,
simd_flag=False,
xip_flag=False,
eh_flag=False,
clean_up_flag=True,
verbose_flag=True,
gc_flag=False,
@ -195,6 +203,9 @@ def test_case(
if xip_flag:
CMD.append("--xip")
if eh_flag:
CMD.append("--eh")
if qemu_flag:
CMD.append("--qemu")
CMD.append("--qemu-firmware")
@ -268,6 +279,7 @@ def test_suite(
multi_thread_flag=False,
simd_flag=False,
xip_flag=False,
eh_flag=False,
clean_up_flag=True,
verbose_flag=True,
gc_flag=False,
@ -291,6 +303,15 @@ def test_suite(
gc_case_list = sorted(suite_path.glob("gc/*.wast"))
case_list.extend(gc_case_list)
if eh_flag:
eh_path = pathlib.Path(EXCE_HANDLING_DIR).resolve()
if not eh_path.exists():
print(f"can not find spec test cases at {eh_path}")
return False
eh_case_list = sorted(eh_path.glob("*.wast"))
eh_case_list_include = [test for test in eh_case_list if test.stem in ["throw", "tag", "try_catch", "rethrow", "try_delegate"]]
case_list.extend(eh_case_list_include)
# ignore based on command line options
filtered_case_list = []
for case_path in case_list:
@ -305,6 +326,7 @@ def test_suite(
simd_flag,
gc_flag,
xip_flag,
eh_flag,
qemu_flag,
):
filtered_case_list.append(case_path)
@ -331,6 +353,7 @@ def test_suite(
multi_thread_flag,
simd_flag,
xip_flag,
eh_flag,
clean_up_flag,
verbose_flag,
gc_flag,
@ -369,6 +392,7 @@ def test_suite(
multi_thread_flag,
simd_flag,
xip_flag,
eh_flag,
clean_up_flag,
verbose_flag,
gc_flag,
@ -428,6 +452,14 @@ def main():
dest="xip_flag",
help="Running with the XIP feature",
)
# added to support WASM_ENABLE_EXCE_HANDLING
parser.add_argument(
"-e",
action="store_true",
default=False,
dest="eh_flag",
help="Running with the exception-handling feature",
)
parser.add_argument(
"-t",
action="store_true",
@ -508,7 +540,7 @@ def main():
if options.target == "x86_32":
options.target = "i386"
if not preflight_check(options.aot_flag):
if not preflight_check(options.aot_flag, options.eh_flag):
return False
if not options.cases:
@ -527,6 +559,7 @@ def main():
options.multi_thread_flag,
options.simd_flag,
options.xip_flag,
options.eh_flag,
options.clean_up_flag,
options.verbose_flag,
options.gc_flag,
@ -552,6 +585,7 @@ def main():
options.multi_thread_flag,
options.simd_flag,
options.xip_flag,
options.eh_flag,
options.clean_up_flag,
options.verbose_flag,
options.gc_flag,