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/1884587513f3c68bebfe9ad759bccdfed8Signed-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:
@ -28,6 +28,9 @@ typedef struct WASMFunctionInstance WASMFunctionInstance;
|
||||
typedef struct WASMMemoryInstance WASMMemoryInstance;
|
||||
typedef struct WASMTableInstance WASMTableInstance;
|
||||
typedef struct WASMGlobalInstance WASMGlobalInstance;
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
typedef struct WASMTagInstance WASMTagInstance;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* When LLVM JIT, WAMR compiler or AOT is enabled, we should ensure that
|
||||
@ -191,6 +194,30 @@ struct WASMFunctionInstance {
|
||||
#endif
|
||||
};
|
||||
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
struct WASMTagInstance {
|
||||
bool is_import_tag;
|
||||
/* tag attribute */
|
||||
uint8 attribute;
|
||||
/* tag type index */
|
||||
uint32 type;
|
||||
union {
|
||||
WASMTagImport *tag_import;
|
||||
WASMTag *tag;
|
||||
} u;
|
||||
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
WASMModuleInstance *import_module_inst;
|
||||
WASMTagInstance *import_tag_inst;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_EXCE_HANDLING != 0
|
||||
#define INVALID_TAGINDEX ((uint32)0xFFFFFFFF)
|
||||
#define SET_INVALID_TAGINDEX(tag) (tag = INVALID_TAGINDEX)
|
||||
#define IS_INVALID_TAGINDEX(tag) ((tag & INVALID_TAGINDEX) == INVALID_TAGINDEX)
|
||||
#endif
|
||||
typedef struct WASMExportFuncInstance {
|
||||
char *name;
|
||||
WASMFunctionInstance *function;
|
||||
@ -211,6 +238,13 @@ typedef struct WASMExportMemInstance {
|
||||
WASMMemoryInstance *memory;
|
||||
} WASMExportMemInstance;
|
||||
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
typedef struct WASMExportTagInstance {
|
||||
char *name;
|
||||
WASMTagInstance *tag;
|
||||
} WASMExportTagInstance;
|
||||
#endif
|
||||
|
||||
/* wasm-c-api import function info */
|
||||
typedef struct CApiFuncImport {
|
||||
/* host func pointer after linked */
|
||||
@ -263,6 +297,14 @@ typedef struct WASMModuleInstanceExtra {
|
||||
WASMTableInstance **table_insts_linked;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
uint32 tag_count;
|
||||
uint32 export_tag_count;
|
||||
WASMTagInstance *tags;
|
||||
WASMExportTagInstance *export_tags;
|
||||
void **import_tag_ptrs;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_MEMORY_PROFILING != 0
|
||||
uint32 max_aux_stack_used;
|
||||
#endif
|
||||
@ -461,6 +503,13 @@ wasm_lookup_memory(const WASMModuleInstance *module_inst, const char *name);
|
||||
|
||||
WASMTableInstance *
|
||||
wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name);
|
||||
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
WASMTagInstance *
|
||||
wasm_lookup_tag(const WASMModuleInstance *module_inst, const char *name,
|
||||
const char *signature);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
|
||||
Reference in New Issue
Block a user