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

@ -1437,6 +1437,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
goto call_func_from_interp;
}
#if WASM_ENABLE_EXCE_HANDLING != 0
HANDLE_OP(WASM_OP_TRY)
HANDLE_OP(WASM_OP_CATCH)
HANDLE_OP(WASM_OP_THROW)
HANDLE_OP(WASM_OP_RETHROW)
HANDLE_OP(WASM_OP_DELEGATE)
HANDLE_OP(WASM_OP_CATCH_ALL)
HANDLE_OP(EXT_OP_TRY)
{
wasm_set_exception(module, "unsupported opcode");
goto got_exception;
}
#endif
/* parametric instructions */
HANDLE_OP(WASM_OP_SELECT)
{
@ -3670,10 +3684,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
#endif
#if WASM_ENABLE_LABELS_AS_VALUES != 0
HANDLE_OP(WASM_OP_UNUSED_0x06)
HANDLE_OP(WASM_OP_UNUSED_0x07)
HANDLE_OP(WASM_OP_UNUSED_0x08)
HANDLE_OP(WASM_OP_UNUSED_0x09)
HANDLE_OP(WASM_OP_UNUSED_0x0a)
#if WASM_ENABLE_TAIL_CALL == 0
HANDLE_OP(WASM_OP_RETURN_CALL)
@ -3688,6 +3698,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP(WASM_OP_REF_NULL)
HANDLE_OP(WASM_OP_REF_IS_NULL)
HANDLE_OP(WASM_OP_REF_FUNC)
#endif
#if WASM_ENABLE_EXCE_HANDLING == 0
/* if exception handling is disabled, these opcodes issue a trap */
HANDLE_OP(WASM_OP_TRY)
HANDLE_OP(WASM_OP_CATCH)
HANDLE_OP(WASM_OP_THROW)
HANDLE_OP(WASM_OP_RETHROW)
HANDLE_OP(WASM_OP_DELEGATE)
HANDLE_OP(WASM_OP_CATCH_ALL)
HANDLE_OP(EXT_OP_TRY)
#endif
/* SELECT_T is converted to SELECT or SELECT_64 */
HANDLE_OP(WASM_OP_SELECT_T)
@ -3695,8 +3715,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP(WASM_OP_UNUSED_0x15)
HANDLE_OP(WASM_OP_UNUSED_0x16)
HANDLE_OP(WASM_OP_UNUSED_0x17)
HANDLE_OP(WASM_OP_UNUSED_0x18)
HANDLE_OP(WASM_OP_UNUSED_0x19)
HANDLE_OP(WASM_OP_UNUSED_0x27)
/* optimized op code */
HANDLE_OP(WASM_OP_F32_STORE)